BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 15
    kumar on in reply to: [Resolved] Can you help me with this code. #36228

    Hi, Brajesh.

    Thanks for replying.

    But the code is not sending email to the user followers when the user publishes a post, here is a complete code.

    
    function wpdocs_set_html_mail_content_type() {
        return 'text/html';
    }
    function post_notification($post_ID) {
        global $wpdb ;
    
        $post = get_post($post_ID) ;
        add_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
    
        $aUsersID = bp_get_following_ids('user_id='.bp_loggedin_user_id() );
        foreach($aUsersID as $iUserID) {
            $user     = get_userdata($iUserID) ;
            
            $to       = $user->user_email ;
            $subject  = '[' . get_bloginfo('name') . '] Nuevo post en el blog' ;
            $message  = 'Nuevo Post: <a href="' . get_permalink($post_ID) . '">' . $post->post_title . '</a>' ;
            $message .= '<br/><br/>' ;
            $message .= nl2br($post->post_content) ;
            wp_mail( $to, $subject, $message ) ;
        }
    }
    
    add_action('publish_post', 'post_notification') ;
  • Participant
    Level: Initiated
    Posts: 15
    kumar on in reply to: [Resolved] Can you help me with this code. #36195

    Any Idea Brajesh?

  • Participant
    Level: Initiated
    Posts: 15
    kumar on in reply to: [Resolved] Can you help me with the small snippet #30608

    Thanks Ravi , it is working fine.

  • Participant
    Level: Initiated
    Posts: 15
    kumar on in reply to: [Resolved] Can you help me with the small snippet #30359

    Any Idea ?

  • Participant
    Level: Initiated
    Posts: 15
    kumar on in reply to: [Resolved] Can you help me with the small snippet #30334

    I am using buddypress legacy template.