Search code examples
phpwordpressbuddypress

I have a question regarding wordpress hook and filter


I would like to replace some text with photo in Buddypress welcome email. I'm new to Wordpress and filter.

<?php
do_action( 'bp_before_email_header' );
echo bp_get_option( 'blogname' );
do_action( 'bp_after_email_header' );
?>

I add a code on function.php like this:

add_action( 'bp_before_email_header', 'add_logo');
function add_logo() {
    echo '<img src="photo url"';
}

There's a photo in email header, however, I would like to remove the text bp_get_option( 'blogname' ); If there's no apply filter, I can not modify it without editing it directly? How can I do that?

Thank you for your help!


Solution

  • bp_get_option has a filter. Check Code. You need simply apply this filter like that for example.

    add_filter('bp_get_option', function($value) {
        if ($value == 'blogname') {
           return '';
        }
    
        return $value;
    }, 10);