• Resolved Dvelop IT

    (@dvelop-it)


    Hi there,

    Just wondering if its possible to do either of the following:

    1. Replace the reply-to email address so that it is the email address of the original author. This would allow forum participants to reply directly to the author.

    2. Alternatively would it be possibly to display the post authors email address in the content of the email. (so we could say “To contact the author directly please email [author-email].”

    Is this something that could be built into the plugin, or could you point me in the direction of which files to modify to allow that to work?

    Thanks,
    Michael

    https://www.ads-software.com/plugins/bbpress-notify-nospam/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author useStrict

    (@usestrict)

    Hi Michael,

    Whatever you do, don’t modify the file itself. You’ll lose your changes with the next update. See below the hooks you can use to achieve what you want. Add your custom hooks and methods either to a custom plugin (preferred) or to your functions.php file (the latter knowing that if you change themes, you lose the functionality).

    For Option 1:

    You can hook into the filter bbpnns_extra_headers to set the reply-to header. To get the author’s information and make it available to your extra headers hook, you can use bbpress_topic_notify_recipients and bbpress_reply_notify_recipients that will contain the Topic ID and Reply ID, respectively.

    $recipients = apply_filters( 'bbpress_topic_notify_recipients', $recipients, $topic_id, $forum_id );
    $recipients = apply_filters( 'bbpress_reply_notify_recipients', $recipients, $reply_id, $topic_id, $forum_id );
    $headers = apply_filters( 'bbpnns_extra_headers', $headers, $recipients, $subject, $body );

    For Option 2:

    Hook into bbpnns_filter_email_body_in_build and process the body however you want.

    $email_body    = apply_filters( 'bbpnns_filter_email_body_in_build', $email_body, $type, $post_id );

    Cheers,
    Vinny

    Plugin Author useStrict

    (@usestrict)

    Closing as resolved, as I haven’t heard back.

    Erik Molenaar

    (@erikmolenaar)

    Hello Vinny,

    I try to hook in to change the Reply-To address, but I can’t get it to work. I have added this code to my functions.php. Can you please tell me what is going wrong here? Thanks for your kind help!

    add_filter( 'bbpnns_extra_headers_recipient' , 'change_the_reply_to_address');
    function change_the_reply_to_address($headers) {
    
    	$contactEmail = '[email protected]';
    	$headers = 'Reply-To: ' . $contactEmail;
    	return $headers;
    
    }
    Plugin Author useStrict

    (@usestrict)

    Hi Erik,

    Try adding the 3rd and 4th parameters to your add_filter call. Also, $headers is an array up until then. You should try to keep it that way.

    Note that I haven’t tested the code below.

    add_filter( 'bbpnns_extra_headers_recipient' , 'change_the_reply_to_address', 1000, 1 );
    
    function change_the_reply_to_address($headers) {
    
    	$contactEmail = '[email protected]';
    
    	if ( is_array( $headers ) )
    	{
    		$found_reply_to = -1;
    
    		foreach ( $headers as $i => $header )
    		{
    			if ( 'reply-to' === substr( strtolower( $header ), 0, 8 ) )
    			{
    				$found_reply_to = $i;
    				break;
    			}
    		}
    
    		if ( -1 !== $found_reply_to )
    		{
    			unset( $headers[$found_reply_to] );
    		}
    
    		$headers[] = 'Reply-To: ' . $contactEmail;
    	}
    	else
    	{
    		// Not array, but really should be
    		$headers .= 'Reply-To: ' . $contactEmail;
    	}
    
    	return $headers;
    }
    Erik Molenaar

    (@erikmolenaar)

    Hello Vinny, thanks for your quick reply! I was just about to remove my above post, as my add_filter hook was already working perfectly without mentioning the 3rd and 4th arguments. Sorry and thanks again!

    Plugin Author useStrict

    (@usestrict)

    My pleasure. Just note that with your code you’re overwriting any additional headers altogether.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Post Authors Email address’ is closed to new replies.