Skip to:

Putting the commentors name back into the notification email

  • Greg


    This is something that I just did on our site and I thought that others might find it useful.

    In standard WordPress / WPMU the comment notification email that is sent to a post author has the commentors name in the from name field of the mail. This is convenient, because you can easily see who’s making comments in your email inbox (e.g. on your phone).

    Buddypress adds a filter that removes this name and replaces it with <site name> for all outgoing mail (from wp_mail()). You can see this filter, ‘bp_core_email_from_name_filter’, in ‘bp_core.php’.

    I replaced that filter with a custom version that only sets the from name to <site name> if the from field is empty, or if it is “WordPress”. It appears to work fine.

    Here is the code. If anyone sees any potential side effects, I’d love to know about it.

    /* replace bp_core filter that sets all from fields to [site name] */
    function replace_email_from_name_filter() {
    remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
    add_filter( 'wp_mail_from_name', '_core_email_from_name_filter' );

    add_action( 'init', 'replace_email_from_name_filter' );

    function _core_email_from_name_filter( $from_name = '' ) {

    if ( $from_name == '' ) {
    $from_name = get_blog_option( 1, 'blogname' );
    } else if ( $from_name == 'Wordpress' ) {
    $from_name = get_blog_option( 1, 'blogname' );

    return $from_name;

    I put this code in ‘bp-custom.php’, which in turn goes in ‘wp-content/plugins’.

  • The topic ‘Putting the commentors name back into the notification email’ is closed to new replies.
Skip to toolbar