Updated solution to removing @mentions
-
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
-
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.
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.
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?
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 profilesI think that’s it…
And I forgot to add…I’m using the Salutation WP Theme
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
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
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.
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 widthif ( !defined( ‘BP_AVATAR_THUMB_HEIGHT’ ) )
define( ‘BP_AVATAR_THUMB_HEIGHT’, 128 ); //change this with your desired thumb heightif ( !defined( ‘BP_AVATAR_FULL_WIDTH’ ) )
define( ‘BP_AVATAR_FULL_WIDTH’, 256 ); //change this to default width for full avatarif ( !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?>
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
- The topic ‘Updated solution to removing @mentions’ is closed to new replies.