Skip to:
Content
Pages
Categories
Search
Top
Bottom

BuddyPress incorrectly overwrites email message headers

  • @kashmiri

    Participant

    BUG REPORT:

    Description: BuddyPress (most recent version) applies the filters to wp_mail in a blanket fashion rather than when they are needed.

    Configuration: BuddyPress (latest) on WP 4.1 along with a contact form plugin which uses wp_mail. Sending message through the form.

    Expected results: Received email message should have headers as specified by the contact form plugin.

    Actual results (when BuddyPress is turned on): “From” header of received email message is overwritten by BuddyPress (with site name or a user display name).

    Discussion of the issue with contact form plugin developer can be read here:

    https://wordpress.org/support/topic/sender-name-3

Viewing 8 replies - 1 through 8 (of 8 total)
  • @shanebp

    Moderator

    Try changing the priority from 10 to 11 in class.cscf_filters.php

    @kashmiri

    Participant

    Thanks for quick answer, but the suggested solution didn’t work, sorry 🙁

    @megnicholas

    Participant

    Hello I am the author of the contact form plugin.

    The problem is that bbpress is adding a filter ‘wp_mail_from_name’ when the plugin is loaded.

    /**
     * Set "From" name in outgoing email to the site name.
     *
     * @uses bp_get_option() fetches the value for a meta_key in the wp_X_options table.
     *
     * @return string The blog name for the root blog.
     */
    function bp_core_email_from_name_filter() {
     	return apply_filters( 'bp_core_email_from_name_filter', bp_get_option( 'blogname', 'WordPress' ) );
    }
    add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );

    My plugin also uses this filter. It applies it just before sending a mail and then removes it afterwards. When applying the filter it also checks whether any other plugin has already changed the from name from the default: ‘WordPress’, if so it does not apply the filter. When BBPress is active, the from name is not the default so the filter is not applied. This has been done so that the plugin works well with other plugins such as wp-mail-smtp which also allows the from name to be set.

    I would like to request that BBPress only applies this filter at the time of sending the mail and then removes it afterwards as it only applies to emails that are sent from BBPress.

    @shanebp

    Moderator

    Did you mean BuddyPress as opposed to bbPress?

    Wouldn’t it be faster to just check for BuddyPress in your plugin and if found remove their filter and then replace it?

    You can always create a ticket in trac. If you do, please reference this thread.

    @kashmiri

    Participant

    Bug report filed here:

    https://buddypress.trac.wordpress.org/ticket/6160

    This has also been pointed out a few years back but issue seems stalled:

    https://buddypress.trac.wordpress.org/ticket/4689

    @r-a-y

    Keymaster

    I’ve closed 6160 in favor of 4689.

    In the meantime, the issue I see with “Contact Form Clean and Simple” plugin is this check in cscf_Filters::wp_mail_from():

    	// If the from email is not the default, return it unchanged
    	if ( $orig != $default_from ) {
    		return $orig;
            }
    

    If you remove that block and bump the priority in cscf_Filters::add() and cscf_Filters::remove() from 10 to something higher as shanebp suggested above, that plugin should work.

    @kashmiri

    Participant

    Thanks! Yes, however the plugin Author mentioned why this check is being done.

    You might be right in suggesting that the contact form plugin could skip the check altogether, esp. that the filter is loaded only temporarily. To my logics, the name passed on by the contact form should take priority (unless modified from plugin options).

    @r-a-y

    Keymaster

    Yes, however the plugin Author mentioned why this check is being done.

    Right, but like you said, if the plugin is only overriding the From name at run-time and if the plugin option says to explicitly override the From name, then the check is redundant.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘BuddyPress incorrectly overwrites email message headers’ is closed to new replies.
Skip to toolbar