Skip to:
Content
Pages
Categories
Search
Top
Bottom

Updated solution to removing @mentions


  • mmaccou
    Participant

    @mmaccou

    I understand there were a few threads about 4 years ago to remove the @mentions. I have tried them but still cant get it to work. I’m thinking because so many changes have occurred since then. Can someone help with an updated version to remove the mention functionality from buddypress? Ideally, I would like to do so by utilizing my child theme if possible

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

  • Tecca
    Participant

    @tecca

    Add this to either bp-custom.php in your plugins folder or to your theme’s functions.php file. It should work for your child theme.

    add_filter( 'bp_activity_do_mentions', '__return_false' );

    Keep in mind that copying+pasting from this forum might not be wise, since it doesn’t seem to preserve code. Either retype the line above or paste it into something like Notepad first.


    mmaccou
    Participant

    @mmaccou

    @tecca

    Thanks for the quick response. I tried this and it didnt work. I put in wp-content/plugins/bp-custom.php. But I still see the mention option.


    Tecca
    Participant

    @tecca

    I just gave it a shot, you’re right. It works and it doesn’t. It doesn’t send notification emails to the user, nor does it send them notifications on-site. It also doesn’t make the username a clickable link. But it still shows up in the “Latest Update” portion in profiles.

    How does it work on your end (or I suppose NOT work)? And if not a custom one, which WordPress theme are you using?

    EDIT: Actually, I just woke up and realized that it works completely on my end. The latest update portion part confused me for a second because I remove that on my development websites and I’m not used to ever seeing it.

    The above is a bit redundant now, but I’ll leave it. Can you say exactly what it is that you’re trying to do? Are you trying to remove the functionality of mentions when a user starts typing the @ symbol and the username?


    mmaccou
    Participant

    @mmaccou

    Hey Tecca,

    I’m having the same experience as you…where it works and doesnt work. It still shows in the Latest Updates section – – I would love to get rid of that as well if you can walk me through it.

    Issues I’m still having that I want to get rid of…

    1. Remove the “Mention this user” button on the profile page of other users
    2. Remove the latest update portion of profiles

    I think that’s it…


    mmaccou
    Participant

    @mmaccou

    And I forgot to add…I’m using the Salutation WP Theme


    Tecca
    Participant

    @tecca

    Ah, gotcha. Alright, so if you want to remove the Mentions tab in user profiles, you’ll need to add this to your bp-custom.php or functions.php file:

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

    To remove the latest update portion in profiles, I think the easiest solution is to open up the member-header.php file located in your theme. It’ll be in a folder called either buddypress or community:

    yourthemelocation/buddypress/members/single/member-header.php

    Find the following line and remove it:

    <span class="activity"><?php bp_last_activity( bp_displayed_user_id() ); ?></span>

    If you can’t find that file in there, it’s because the theme author hasn’t edited it specifically for the theme. You can simply drop it in the folder if it’s not there and then edit it. It’s originally located in the /plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single folder


    mmaccou
    Participant

    @mmaccou

    I’m struggling here lol. I tried both things and neither are working. When I enter the above code it doesnt seem to have an effect


    Tecca
    Participant

    @tecca

    Can you paste the contents of your bp-custom.php here (or somewhere like Pastebin with a link if it’s really large).

    Also, if you’re using a caching plugin, make sure it’s deactivated. Also try refreshing your page with a hard refresh a couple of times using CTRL+F5.


    mmaccou
    Participant

    @mmaccou

    Hey @tecca

    Here is the bp-custom…

    <?php

    if ( !defined( ‘BP_AVATAR_THUMB_WIDTH’ ) )
    define( ‘BP_AVATAR_THUMB_WIDTH’, 128 ); //change this with your desired thumb width

    if ( !defined( ‘BP_AVATAR_THUMB_HEIGHT’ ) )
    define( ‘BP_AVATAR_THUMB_HEIGHT’, 128 ); //change this with your desired thumb height

    if ( !defined( ‘BP_AVATAR_FULL_WIDTH’ ) )
    define( ‘BP_AVATAR_FULL_WIDTH’, 256 ); //change this to default width for full avatar

    if ( !defined( ‘BP_AVATAR_FULL_HEIGHT’ ) )
    define( ‘BP_AVATAR_FULL_HEIGHT’, 256 ); //change this to default height for full avatar

    /* deactivate @mention – BP 2.0+ & bbpress */

    add_filter( ‘bp_activity_do_mentions’, ‘__return_false’ );
    add_filter( ‘bbp_find_mentions’, ‘__return_false’ ); //bbPress only

    ?>


    danbp
    Participant

    @danbp

    To remove @username near the header avatar on profile page, use this (in bp-custom.php)

    function bpfr_remove_mention_from_profile() {	
    	// hide the hardcoded @ sign and username
    	echo '<style> h2.user-nicename { display:none; } </style>';
    
    	if( bp_is_user() && ! bp_get_member_user_id() ) {
            $user_id = 'displayed: '. bp_displayed_user_id();
        } else {
            $user_id = 'get_member_user: '. bp_get_member_user_id();
        }
    
    	remove_filter( 'bp_get_displayed_user_mentionname', bp_activity_get_user_mentionname( bp_displayed_user_id() ) );
    	
    }
    add_filter( 'bp_get_displayed_user_mentionname', 'bpfr_remove_mention_from_profile' ); 

    To remove the mention sub tab from profile page, use this (in bp-custom.php):

    
    function bpfr_hide_mention( $retval = 1 ) {
    	$retval = false;
    	// condition 
    	if ( bp_is_user() && ! bp_is_my_profile() ) {
    		$retval = true;
    	}	
    	return $retval;
    }
    
    function bpfr_hide_mention_nav() {	
    	// stop if condition is not ok
    	if ( ! bpfr_hide_mention() ) {
    		return;
    	}
    	// otherwise we remove the nav item
    	//bp subnav items
    	bp_core_remove_subnav_item( 'activity', 'mentions' ); 
    }
    add_action( 'bp_ready', 'bpfr_hide_mention_nav' );

    To unlink @mention (this removes only the link not the mentionned username) AND remove the public message button, use this (in bp-custom.php):
    add_filter( 'bp_activity_do_mentions', '__return_false' );

    To allow the new BP 2.1 @mention tool in bbPress, use this (in bp-custom.php):

    
    function bpfr_bbpress_maybe_load_mentions_scripts( $retval = false ) {
    	if ( function_exists( 'bbpress' ) && is_bbpress() ) {
    		$retval = true;
    	}
     
    	return $retval;
    }
    add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bpfr_bbpress_maybe_load_mentions_scripts' );

    Tested with WP 4.1 – BP 2.1.1 – bbP 2.5.4

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Updated solution to removing @mentions’ is closed to new replies.
Skip to toolbar