Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • bringmesupport
    Participant

    @bringmesupport

    The BuddyPress Codex explains how to do this here:

    Theme Compatibility & Template Files

    You were on the right track, but you are copying the wrong files from the BuddyPress core. If you want to override the BuddyPress Templates in your own theme, you would copy the files you wanted to override from wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress to /wp-content/themes/myTheme/buddypress, just keep the file structure intact in your theme.

    For example, if you just wanted to modify the members loop, copy just the members-loop.php file from wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/members-loop.php and paste just that file to /wp-content/themes/myTheme/buddypress/members/members-loop.php in your theme. If the folders don’t already exist in your theme, just create them.


    bringmesupport
    Participant

    @bringmesupport

    It is trivial for a hacker to get your username. If you are concerned with security, I would be more concerned with implementing security features such as timeouts/lockouts for a certain number of failed password attempts, making sure you have a really strong password, using HTTPS for starters.


    bringmesupport
    Participant

    @bringmesupport

    Hi @fptquangngai,

    I am assuming you are referring to the name shown in the screenshot below:

    Screenshot

    This name you want to change is coming from the line bp_core_get_userlink( $user_id ); in the snippet you provided, which is part of the bp_message_get_recipient_tabs() function defined in the BuddyPress plugin under bp-members > admin > bp-members-functions.php.

    It seems there are two things you can do here:

    1. You can replace the bp_core_get_userlink() function in the message template (located at wp-content\plugins\buddypress\bp-templates\bp-legacy\buddypress\members\single\messages\compose.php) with your own custom function. See BuddyPress Codex for how to properly do this.

    OR

    2. Create a filter.

    Since the bp_core_get_userlink() function uses the ‘bp_core_get_userlink’ filter for the returned value, you can hook into this filter and modify it in your theme’s functions.php file (or your own custom plugin). The only problem is that since the bp_core_get_userlink() function is used in other parts of the code (notably the BuddyPress Login Widget), you will have to make it so that the custom filter is used only under certain conditions.

    Here is the custom filter I came up with. Its not refined, but serves as a working example:

    
    add_filter( 'bp_core_get_userlink', 'my_bp_filter', 10, 2 );
    function my_bp_filter( $string, $user_id ){  
        global $pagename;
        if ( isset( $_GET['r']) && $pagename === 'compose' ){
            $username = bp_core_get_username( $user_id );
            if ( $_GET['r'] === $username ) {
                $string = explode(' ', $string);
                $string = $string[0]. ' '. $string[1]. 'Alt="' . $username . '">'. $username . '</a>';
            }
        }
        return $string;
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
Skip to toolbar