bbPress Forum Reply URL's duplicated in Email Notifications

When people are notified of a new forum post the footer in the email says:

Reply Url: /forums/topic/how-was-everyones-christmas/#post-23061

Author: mary

You can reply at: /forums/topic/how-was-everyones-christmas/#post-23061

How do I get rid of one or the other? There is no need for the duplication.
Support Access is granted.
Thank you.

  • Sajid

    Hello Mary :slight_smile:

    I tested that plugin on my own site and it worked just fine. I did not noticed any weird styling issues on forum topics/replies on my end when this plugin was active. Also, I checked the source code of the plugin and suppose to do nothing on front-end of site.

    However, I try to come up with following code snippet that you can add in functions.php file of your child theme or use it as mu-plugin.

    add_filter( 'bbp_forum_subscription_mail_message', 'wpmudev_bp_custom_topic_message' , 10, 3 );
    
    function wpmudev_bp_custom_topic_message( $message, $topic_id, $forum_id ) {
    
            $topic_content  = strip_tags( bbp_get_topic_content( $topic_id ) );
            $topic_url      = bbp_get_topic_permalink( $topic_id );
            $topic_author   = bbp_get_topic_author_display_name( $topic_id );
            $forum_name     = bbp_get_forum_title( $forum_id );
    
            $custom_message = '{author} wrote:
    
                                {content}
    
                                Post Link: {url}
    
                                -----------
    
                                You are receiving this email because you subscribed to the {forum_name} forum.
    
                                Login and visit the forum to unsubscribe from these emails.';
    
            $message = $custom_message ? $custom_message : $message;
    
            $message = str_replace( '{author}',  $topic_author,  $message );
            $message = str_replace( '{content}', $topic_content, $message );
            $message = str_replace( '{url}',     $topic_url,     $message );
            $message = str_replace( '{forum_name}', $forum_name, $message );
    
            return $message;
        }
    
    add_filter( 'bbp_subscription_mail_message', 'wpmudev_bp_custom_reply_message' , 10, 3 );
    
    function wpmudev_bp_custom_reply_message( $message, $reply_id, $topic_id ) {
    
            $reply_content  = strip_tags( bbp_get_reply_content( $reply_id ) );
            $reply_url      = bbp_get_reply_url( $reply_id );
            $reply_author   = bbp_get_reply_author_display_name( $reply_id );
    
            $custom_message = '{author} wrote:
    
                                {content}
    
                                Post Link: {url}
    
                                -----------
    
                                You are receiving this email because you subscribed to the {forum_name} forum. 
    
                                Login and visit the forum to unsubscribe from these emails.';
    
            $message = $custom_message ? $custom_message : $message;
    
            $message = str_replace( '{author}',  $reply_author,  $message );
            $message = str_replace( '{content}', $reply_content, $message );
            $message = str_replace( '{url}',     $reply_url,     $message );
    
            return $message;
        }

    Now feel free to edit the text in $custom_message variable in both functions according to your requirements. Text wrapped with curly braces ({}) in custom message are meant to be replaced dynamically according to topics/replies.

    Take care and have a nice day!

    Best Regards,
    Sajid

  • Sajid

    Hello Mary :slight_smile:

    Apologies for any inconvenience. However, I am using the same code as mu-plugin on my own localhost site with bbPress plugin and it worked fine over there.

    In case you are still looking for the solution as mu-plugin, I am attaching the plugin as a zip file with this reply.

    Here are the steps to use this mu-plugin.

    1. Download the file attached with this reply on your computer.

    2. Extract/unzip it.

    3. Navigate to following location on your server via FTP program like FileZilla or FileManager of cPanel.
    wp-content/mu-plugins
    (create mu-plugins folder if not exists in wp-content folder)

    4. Now upload the file we downloaded/extracted previously.

    Note: It is strongly recommended to take full backup of your site before installing any plugin, mu-plugin or theme.

    Take care and have a nice day!

    Best Regards,
    Sajid