• Dear all,

    I can’t find the way to make an email sent to all buddyPress group’s participants (members) when an event has been created for that specific group.

    How/where to set this up?

    Thanks

Viewing 1 replies (of 1 total)
  • I think the following code snippet should do what you’re requesting.

    add_action('em_event_save', 'my_em_group_event_save', 10, 2);
    function my_em_group_event_save($result, $EM_Event) {
        if (is_object($EM_Event) && $EM_Event->group_id) {
            $group = groups_get_group( array( 'group_id' => $EM_Event->group_id ) );
            $post = get_post( $EM_Event->post_id );
            $subject = sprintf( 'New post in %s: %s', $group->name, $post->post_title );
            $message = sprintf( 'A new event has been added to the group "%s". To view the event, click the link below:%s%s', $group->name, "\n\n", get_permalink( $post_id ) );
            $headers = array( 'Content-Type: text/html; charset=UTF-8' );
            $recipient_list = array();
            $members = groups_get_group_members( array( 'group_id' => $group_id ) );
            foreach ( $members['members'] as $member ) {
                $recipient_list[] = $member->user_email;
            }
            wp_mail( $recipient_list, $subject, $message, $headers );
        }
        return $result;
    }

    You can use the WPCode plugin to help you add the code snippet on your website.

Viewing 1 replies (of 1 total)
  • The topic ‘Email alerts on BuddyPress group’s event creation’ is closed to new replies.