Skip to:
Content
Pages
Categories
Search
Top
Bottom

Conflict with Buddypress and WordPress Email


  • Dono12
    Participant

    @dono12

    I created a plugin which sends custom emails to users when they Register, Submit Post, Comment on a Post (email to post author), and Reset Password.
    Problem is all the styles are missing from the Buddypress Email notification when my custom WordPress Email Notification Plugin is Active. When I deactivate my Custom WordPress Plugin all the styles for Buddypress email Notifications return.

    I know one can’t have it all but geee’s. I would like users to get a nice email message when interacting with b all aspects of my site. How can I fix this issue?

Viewing 4 replies - 1 through 4 (of 4 total)

  • Paul Wong-Gibbs
    Keymaster

    @djpaul

    Is your plugin online somewhere? Share a link?


    Dono12
    Participant

    @dono12

    No, the plugin is not online. I built it with bits of code and tuts across the web about customizing WordPress notification emails. if you can send me an email address (please black this out **** (removed at users request ~hnla)) I can send you the plugin and you look it over. I saw on the web that you should remove filter after applying it but it didn’t seem to have any affect.

    remove_filter( 'wp_mail_content_type','mycustom_mail_content_type' );


    Dono12
    Participant

    @dono12

    Hi, Paul. If you cold be so kind to remove the email and site UrL from my correspondence. I added the plugin code to Post bin where you can take a look. Pastebin


    Dono12
    Participant

    @dono12

    I figured out the solution. I had to call

    add_filter( ‘wp_mail_content_type’, ‘notification_content_type’ );

    in each individual email function:

    add_filter( 'wp_mail', 'dirty_wp_mail_filter' );
    function dirty_wp_mail_filter( $args ) {
    
    	// you can include your custom html mail template here
    	// just use file_get_contents() functions to get template file and any php replace function like
    	// str_ireplace or preg_replace to replace your given placeholder in template by the content which is sent by wp
    
    	$stripped_mail_content = preg_replace("/<http(.*)>/m", "http$1", $args['message']);
    	add_filter( 'wp_mail_content_type', 'dirty_notification_content_type' );
    	$dirty_wp_mail = array(
    		'to'          => $args['to'],
    		'subject'     => $args['subject'],
    		'message'     => $stripped_mail_content,
    		'headers'     => $args['headers'],
    		'attachments' => $args['attachments']
    	);
    	return $dirty_wp_mail;
    }
    
    function dirty_notification_content_type() {
    	return 'text/html';
    }

    found here:
    core.trac.wordpress.org/ticket/21095

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.