BuddyDev

Search

[Resolved] Getting started / hide the @username

Tagged: ,

  • Participant
    Level: Enlightened
    Posts: 32
    Gisela Zechner on #51302

    Hello BuddyDev-Team,

    1. I am just starting with Buddypress: I am puzzled about the theme. At the moment I have installed AVADA – Can I use the AVADA theme, it is one of the most used Word-Press-themes and I like it. Do I need to use a BuddyDev Theme?
    – Since one of the last updates of buddypress, wordpress, or avada I noticed that the basic Pages of Buddypress like “activity” is no longer listed in the Page-list. Due to this I cannot edit the Startpage of Buddypress.

    2. The contact list displays the @username. This does not look like very nice and furthermore it can be of risk for security. How can I hide the username on the profile.

    Best wishes
    Gisela

  • Participant
    Level: Guru
    Posts: 886
    Tosin on #51305

    Hi

    Regarding the security issue I think you don’t need to hide the username, you can disable login by username and enable login by only email. Email addresses arent publicly displayed there by improving login security. I was able to achieve this with the code below.

     // Function to log in with email instead of username
    function use_email_for_login($user, $username, $password) {
        if (!empty($username) && !empty($password)) {
            // Check if the entered username is an email
            if (is_email($username)) {
                // Get the user by email
                $user = get_user_by('email', $username);
                if (!$user) {
                    // Email not found, return an error
                    return new WP_Error('invalid_email', __('Invalid email or password.'));
                } else {
                    // Authenticate the user with the retrieved username
                    $username = $user->user_login;
                    $user = wp_authenticate_username_password(null, $username, $password);
                    if (is_wp_error($user)) {
                        // Authentication failed, return an error
                        return new WP_Error('invalid_login', __('Invalid email or password.'));
                    }
                }
            } else {
                // If the entered username is not an email, return an error
                return new WP_Error('invalid_email_format', __('Invalid email or password.'));
            }
        }
        return $user;
    }
    add_filter('authenticate', 'use_email_for_login', 20, 3); 
  • Participant
    Level: Enlightened
    Posts: 32
    Gisela Zechner on #51307

    Hi,

    thank you for the code, nevertheless it doesn’t help to hide the @username. I want hide the @username because it doesn’t look like nice and I think that a lot of the members don’t want that the @username is displayed. How can I hide the @username?

    Thanks for answer in advance.

  • Participant
    Level: Guru
    Posts: 886
    Tosin on #51308

    There are various options depending if you want to partially diasable @mentions or completely disable it.

    1.

    add_filter( 'bp_activity_do_mentions', '__return_false' );

    2. Removes mentions pane from profile activity (doesn’t remove mention functionality)

    
     function remove_mention_nav() {
    global $bp;
    bp_core_remove_subnav_item( $bp->activity->slug, 'mentions' );
    }
    add_action( 'bp_setup_nav', 'remove_mention_nav', 15 ); 
    

    3.Just hide with css

    
     /* Hide username in BuddyPress profile header */
    #item-header .username {
        display: none;
    } 
    

    4. Just disable public message feature in buddypress settings

  • Participant
    Level: Enlightened
    Posts: 32
    Gisela Zechner on #51310

    Thanks a lot for the prompt support. I’ll try it out.

  • Participant
    Level: Enlightened
    Posts: 32
    Gisela Zechner on #51314

    Hi Tosin,

    Thanks for your support – I’ve just tried to disable public message feature in buddypress settings. Dashboard > Settings > Buddypress > Options/Components but I could not find any option to disable public messages.

    Thanks in advance
    Gisela

  • Participant
    Level: Enlightened
    Posts: 32
    Gisela Zechner on #51316

    I’ve found the following Code in an other forum post:

    ‘add_filter( ‘bp_get_send_public_message_button’, ‘__return_empty_array’ );’

    it works well und has disabled the public Message button in the list.

    Best wishes
    Gisela

  • Participant
    Level: Guru
    Posts: 886
    Tosin on #51318

    Hi apologies for the confusion I meant (Disable
    Activity Streams) feature. The @username feature is enabled when the Activity Streams feature is enabled

  • Participant
    Level: Enlightened
    Posts: 32
    Gisela Zechner on #51319

    Hi, thanks a lot for your help,
    I’ve now hidden the public message button and the @username. That’s fine for me.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2948
    Ravi on #51328

    Hello Giesela,

    Thank you for sharing the acknowledgement. I am glad that You have resolved the issue on your own


    @tosin
    , Thank you for helping.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: resolved