vahid mohammadi (@wvmohzoibar)

Forum Replies Created

Viewing 1 replies (of 1 total)
  • @wvmohzoibar

    Participant

    Hi
    you can use this code:

    add_action( 'bbp_new_reply',  'update_reply', 0, 6 );
    function update_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false ) {
    
    	$reply_id = bbp_get_reply_id( $reply_id );
    	$topic_id = bbp_get_topic_id( $topic_id );
    
    	if ( !bbp_is_topic_published( $topic_id ) || !bbp_is_reply_published( $reply_id ) ) return;
    
    	// $topic_email = bbp_get_topic_author_email($topic_id);
    	if (!empty($topic_id)) {
    		// if user is anonymous
    		if (bbp_is_topic_anonymous($topic_id)) {
    			$author_email = get_post_meta($topic_id, '_bbp_anonymous_email', true);
    			if ($author_email == 'nobody@example.com') return;
    
    			$topic_title   = strip_tags( bbp_get_topic_title( $topic_id ) );
    			$reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
    			$reply_url     = bbp_get_reply_url( $reply_id );
    			$blog_name     = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    
    			$email_subject = $blog_name . ': ' . __( 'New reply to your topic', 'etuts' ) . '"' . $topic_title . '"';
    			$email_content = __( "New reply to your topic\nIn order to view the reply, open the bellow link\n", 'etuts' ) . $reply_url;
    
    			wp_mail( $author_email, $email_subject, $email_content );
    		}
    	}
    }
    
Viewing 1 replies (of 1 total)