PS. Maybe hide by member type? or in the admin panel is there a checkbox? When I check ” Exclude user from Author-sitemap” the member still shows up under members.
In short I need this code to redirect to 404 page not homepage. Thank you.
// deny access to admins profile. User is redirected to the homepage
function bpfr_hide_admins_profile() {
global $bp;
if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
wp_redirect( home_url() );
exit;
endif;
}
add_action( 'wp', 'bpfr_hide_admins_profile', 1 );
I found the solution:
// Exclude Admins from Directories and BP Widgets
add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
function buddydev_exclude_users( $args ) {
//do not exclude in admin
if( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return $args;
}
$excluded = isset( $args['exclude'] )? $args['exclude'] : array();
if( !is_array( $excluded ) ) {
$excluded = explode(',', $excluded );
}
$user_ids = array( 1, ); // enter user ids here
$excluded = array_merge( $excluded, $user_ids );
$args['exclude'] = $excluded;
return $args;
}
// Deny access to admins profile. User is redirected to the homepage
function bpfr_hide_admins_profile() {
global $bp;
if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
wp_redirect( home_url() );
exit;
endif;
}
add_action( 'wp', 'bpfr_hide_admins_profile', 1 );
// Hide admin's activities from all activity feeds
function bpfr_hide_admin_activity( $a, $activities ) {
// ... but allow admin to see his activities!
if ( is_site_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
// ID's to exclude, separated by commas. ID 1 is always the superadmin
if ( $activity->user_id == 1 ) {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
}
}
// Renumber the array keys to account for missing items
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action( 'bp_has_activities', 'bpfr_hide_admin_activity', 10, 2 );
Solution: HIDE ADMIN FROM BP WIDGETS AND DIRECTORY
This code is complementary for the other ==>
Hiding Users on BuddyPress based site
So, full code:
// Exclude Admin from Directories and BP Widgets
add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
function buddydev_exclude_users( $args ) {
//do not exclude in admin
if( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return $args;
}
$excluded = isset( $args['exclude'] )? $args['exclude'] : array();
if( !is_array( $excluded ) ) {
$excluded = explode(',', $excluded );
}
$user_ids = array( 1, ); // enter user ids here
$excluded = array_merge( $excluded, $user_ids );
$args['exclude'] = $excluded;
return $args;
}
// Deny access to admins profile. User is redirected to the homepage
function bpfr_hide_admins_profile() {
global $bp;
if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
wp_redirect( home_url() );
exit;
endif;
}
add_action( 'wp', 'bpfr_hide_admins_profile', 1 );
// Hide admin's activities from all activity feeds
function bpfr_hide_admin_activity( $a, $activities ) {
// ... but allow admin to see his activities!
if ( is_site_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
// ID's to exclude, separated by commas. ID 1 is always the superadmin
if ( $activity->user_id == 1 ) {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
}
}
// Renumber the array keys to account for missing items
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action( 'bp_has_activities', 'bpfr_hide_admin_activity', 10, 2 );
@danbp
Hi!
Can you help me?
How I can hide super admin’s vcard from BuddyPress Widgets??
Your code only hide super admin from members and activity…
// Deny access to admins profile. User is redirected to the homepage
function bpfr_hide_admins_profile() {
global $bp;
if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
wp_redirect( home_url() );
exit;
endif;
}
add_action( ‘wp’, ‘bpfr_hide_admins_profile’, 1 );
// Hide admin’s activities from all activity feeds
function bpfr_hide_admin_activity( $a, $activities ) {
// … but allow admin to see his activities!
if ( is_site_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
// ID’s to exclude, separated by commas. ID 1 is always the superadmin
if ( $activity->user_id == 1 ) {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
}
}
// Renumber the array keys to account for missing items
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action( ‘bp_has_activities’, ‘bpfr_hide_admin_activity’, 10, 2 );
// Remove admin from the member directory
function bpdev_exclude_users($qs=false,$object=false){
$excluded_user=’1′; // Id’s to remove, separated by comma
if($object != ‘members’ && $object != ‘friends’)// hide admin to members & friends
return $qs;
$args=wp_parse_args($qs);
if(!empty($args[‘user_id’]))
return $qs;
if(!empty($args[‘exclude’]))
$args[‘exclude’] = $args[‘exclude’].’,’.$excluded_user;
else
$args[‘exclude’] = $excluded_user;
$qs = build_query($args);
return $qs;
}
add_action(‘bp_ajax_querystring’,’bpdev_exclude_users’,20,2);
// once admin is removed, we must recount the members !
function bpfr_hide_get_total_filter($count){
return $count-1;
}
add_filter(‘bp_get_total_member_count’,’bpfr_hide_get_total_filter’);
@henrywright
This work okey –>: but, How I can Hide Admin from BuddyPress Widget??
—->
// Deny access to admins profile. User is redirected to the homepage
function bpfr_hide_admins_profile() {
global $bp;
if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
wp_redirect( home_url() );
exit;
endif;
}
add_action( 'wp', 'bpfr_hide_admins_profile', 1 );
// Hide admin's activities from all activity feeds
function bpfr_hide_admin_activity( $a, $activities ) {
// ... but allow admin to see his activities!
if ( is_site_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
// ID's to exclude, separated by commas. ID 1 is always the superadmin
if ( $activity->user_id == 1 ) {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
}
}
// Renumber the array keys to account for missing items
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action( 'bp_has_activities', 'bpfr_hide_admin_activity', 10, 2 );
// Remove admin from the member directory
function bpdev_exclude_users($qs=false,$object=false){
$excluded_user='1'; // Id's to remove, separated by comma
if($object != 'members' && $object != 'friends')// hide admin to members & friends
return $qs;
$args=wp_parse_args($qs);
if(!empty($args['user_id']))
return $qs;
if(!empty($args['exclude']))
$args['exclude'] = $args['exclude'].','.$excluded_user;
else
$args['exclude'] = $excluded_user;
$qs = build_query($args);
return $qs;
}
add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
// once admin is removed, we must recount the members !
function bpfr_hide_get_total_filter($count){
return $count-1;
}
add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter');
https://wordpress.org/plugins/admin-tools/
This one claims to be able to hide parts of the admin bar
For points 1 and 2 you need to ask at the BuddyDev forums as they are not BP issues.
For point 3 you can edit BuddyPress emails in Dashboard>>Emails.
For point 4 there’s some plugins that will hide the admin bar for certain user types, I’ve not tried them but try searching the WordPress plugin repository one I saw that might do the trick is https://wordpress.org/plugins/better-admin-bar/
I’ve installed Buddypress, Buddyblog and the latest version of BP Simple Front End Post: http://babyitsourworld.com
1. When a user begins to create a post, they do not have an option to upload a featured image. How do I fix this? A featured image should be required – See Screenshot: http://bit.ly/2fNRlNU
2. The style of the page is too long. How do we make the Category and Tags split the page 1/2 & 1/2 with contained list? This will shorten the page greatly – See screenshot: http://bit.ly/2fNRlNU
3. One of our users tried to register and got the confirmation email in their spam folder. So can we edit the email copy to: “BTW: Be sure to add B.O.W. to your contacts in order not to get these emails to your spam folder or in any other dark corner of your inbox.”
How do I do this for the BuddyPress email confirmation?
4. How do I hide/remove ONLY the top left parts of the Admin from users? User should not be able to see the dashboard. Only the Admin. Screenshot: http://bit.ly/2g1aOxp
Thanks in Advance.
Hello I had a question in continuation of the topic below ref removing the delete-group from group admins using the code provided below :
https://buddypress.org/support/topic/how-to-remove-tabs-from-group-admin-nav-2/#post-261003
function turker_remove_group_admin_tab() {
if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
return;
}
// Add the admin subnav slug you want to hide in the
// following array
$hide_tabs = array(
'group-avatar' => 1,
'delete-group' => 1,
);
$parent_nav_slug = bp_get_current_group_slug() . '_manage';
// Remove the nav items
foreach ( array_keys( $hide_tabs ) as $tab ) {
bp_core_remove_subnav_item( $parent_nav_slug, $tab );
}
// You may want to be sure the user can't access
if ( ! empty( $hide_tabs[ bp_action_variable( 0 ) ] ) ) {
bp_core_add_message( 'Sorry buddy, but this part is restricted to super admins!', 'error' );
bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );
}
}
Dan writes:
Get Ready! 2.4.0 will introduce important changes in Groups homes
“The function is still working, but not completely (tabs aren’t hidden). You probably need to complete it with $component (read above document)”
This code was written circa 2.2. Im not sure where/how to add the $component to get the code to work. Any assistance is appreciated thank you.
I have:
a.- Updated to BP 2.7.2. <– Still same problems but warnings hidden by my code.
b.- Removed the buddypress folder in my theme with edited files and checked. <– Still same problems: Warnings (as my code did not hide them), “Moderators” tag and “no mods” string.
c.- Downloaded and activated Twenty Sixteen theme. <– Same as in previous step.
And I get the same warning explained in the first entry in this post so it’s not about my modified files and it’s not about a theme problem.
There are still two problems:
1.- The warning points to get_group_moderator_ids( $group_id ) in /wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-member.php
I don’t have (or have had) moderators in any group so, “Creating default object from empty value” <– What default object from what empty value?
2.- The problem is somewhere else: In line 33 of the group-header.php file (in groups/single/ ) we find this line:
if ( bp_group_has_moderators() ) :
where “bp_group_has_moderators()” is giving a false “true” value as I don’t have moderators in any group so it should not execute in the first place. And after the Moderators tag it says “no mods”, so it on a later step recognizes there are no moderators!!!
Has the bp_group_has_moderators() function or get_group_moderator_ids( $group_id ) function been altered? Or the data about mods and/or admins in the groups?
Because one of them creates two warnings (one before listing the admins and one before listing the mods) that were not there before and also shows a “Moderators” tag that did not appear as the if ( bp_group_has_moderators() ) returned the FALSE value my no-mods groups “deserve” (which it later recognizes when adding the “no mods” string) that now returns this “buggy” TRUE value and shows the tag.
Hi, I’m using the plugin BuddyPress Admin Only Profile Fields to hide certain xprofile fields, I have quite a few, when viewing the admin EDIT (front view) page, it shows a blank white screen. I cannot figure out whats wrong with the site, if anyone can help I’d greatly appreciate it.
Hi, I have previously been asked to set my site up so that buddyprerss members’ profiles can not be found by search engines. They want theme to only be accessible by visiting the site. I have put a robots file on my site (see below) but am still getting profiles appearing in searches – please can you tell me if there is anything I need to add to the file. Thanks, Matt.
User-agent: *
Disallow: */activity/p/*
Disallow: /docs/
Disallow: *send-invites*
Disallow: */groups/*members*
Disallow: */groups/*media*
Disallow: *widget-title*
Disallow: *members/*activity*
Disallow: *members/*notifications*
Disallow: *members/*friends*
Disallow: *members/*groups*
Disallow: *members/*docs*
Disallow: *members/*media*
Disallow: *acpage*
Disallow: *messages*
Disallow: *friends*
Disallow: *settings*
Disallow: /*/comment-page*
Disallow: *register*
Disallow: *login*
Disallow: *profile*
Disallow: *admin*
Disallow: *includes*
Disallow: *content*
Hi,
I’d like to be able to hide the header, footer and sidebar that appears in a member’s profile.
I’ve had a read and have found how to do it using a child theme, but I am just using the plugin, not the theme.
I’ve tried using the bp-custom.php file.
Firstly with the following which I have inserted as Custom CSS (via my OptimizePress theme’s inbuilt option) on posts where I want the same things hidden.
.banner{display:none;}
#nav-top{display:none;}
#nav-bottom{display:none;}
.page-header{display:none}
.in-page-ad {display: none}
.op-author-info {display: none}
.footer-content {display: none}
.wpadminbar {display: none}
It didn’t like this and the other things I tried here didn’t seem to do anything.
Any help with what I can do would be greatly appreciated 🙂
Thanks,
Jon
hi @masoud1111,
all i found was how to hide that button, or remove it.
but not show it only on some profiles
You just need to add some conditionnals.
Try this (in bp-custom.php) and give feed back if it works.
function bpex_private_message_button( $button ) {
$user = bp_loggedin_user_id();
if ( is_super_admin() ) {
return $button;
}
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
if ( $role == 'subscriber' || $role == 'contributor' || $role == 'author' || $role == 'editor' ) {
// hide button for these roles
$button = '';
}
}
// allow the button to appear on admin's profile only
if ( bp_is_active( 'xprofile' ) && bp_is_user() ) {
$user_id = bp_displayed_user_id();
// assuming admin's ID is 1
if ( $user_id == 1 ) {
return $button;
}
}
}
add_filter( 'bp_get_send_message_button', 'bpex_private_message_button', 1 , 1 );
Nothing to do!
Error:
Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/mondolap/public_html/wp-content/plugins/bp-custom.php on line 3
This is the bp-custom code:
<? php
function buddydev_hide_members_directory_from_all_except_admin() {
if ( bp_is_members_directory() && ! is_super_admin() ) {
//should we add a message too?
//bp_core_add_message( ‘Private page.’, ‘error’ );
bp_core_redirect( site_url(‘/’) );
}
}
add_action( ‘bp_template_redirect’, ‘buddydev_hide_members_directory_from_all_except_admin’ );
The function is working correctly on my install.
Perhaps you have an issue with quotes, ie after copy/pasting the snippet from a topic where the code whas inserted without using the code button.
Which software do you use to publish bp-custom ?
Copy/paste following and give a try:
function buddydev_hide_members_directory_from_all_except_admin() {
if ( bp_is_members_directory() && ! is_super_admin() ) {
//should we add a message too?
//bp_core_add_message( 'Private page.', 'error' );
bp_core_redirect( site_url('/') );
}
}
add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );
Thanks! I did it with your suggest, so the file is
<? php
function buddydev_hide_members_directory_from_all_except_admin() {
if ( bp_is_members_directory() && ! is_super_admin() ) {
//should we add a message too?
//bp_core_add_message( 'Private page.', 'error' );
bp_core_redirect( site_url('/') );
}
}
add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );
But every page of the website is now again a blank page with this error:
Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/mondolap/public_html/wp-content/plugins/bp-custom.php on line 2
@sbrajesh
Hello and thanks for the support, I tried the solution suggested, but after I created and then uploaded the file bp-custom in the plugins folder I got an error in every page of the website:
Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/mondolap/public_html/wp-content/plugins/bp-custom.php on line 2
This is my file bp-custom:
<? php
function buddydev_hide_members_directory_from_all_except_admin() {
if ( bp_is_members_directory() && ! is_super_admin() ) {
//should we add a message too?
//bp_core_add_message( 'Private page.', 'error' );
bp_core_redirect( site_url('/') );
}
}
add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );
?>
It relate to this filter bp_get_profile_field_data
This example will hide tabs and fields to all except admin
function bpfr_hide_profile_field_group( $retval ) {
if ( bp_is_active( 'xprofile' ) ) :
// hide profile group/field to all except admin
if ( !is_super_admin() ) {
//exlude fields, separated by comma
$retval['exclude_fields'] = '1';
//exlude groups, separated by comma
$retval['exclude_groups'] = '3';
}
return $retval;
endif;
}
add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
These tricks hide the tab content, not the tab itself. (it seems that it doesn’t work for groups at the moment…i asked devs for information) Use CSS display:none to hide the tab or consider this plugin.
@danbp
Thanks again.
I’d missed the second example, but, unfortunately, it doesn’t solve the issue.
If not enough, you use CSS display:none; for the BASE markup on profile edit tab.
I attempted to do this but I’m unable to target the BASE group without also affecting the USER INFO group
I noticed, too, that the “hide fields or field group to members, but not to site admin” code was preventing user registrations from going through, for some reason. It was quickly redirecting users to the home page, rather than a success or failure message page, when they clicked on the “complete sign up” button.
I think what I’ll have to do is put all fields in the BASE group & go with what @shanebp suggested in the thread I linked in my first post. & hope that potential subscribers aren’t put off by the registration form.
I will be your savior,
for same rasons, wordpress decided not show admin bar like default in mobile.
It is so,maybe, because when user log in in mobile device, a lot of menu will be showed… really I dont know why…
But if you dont have this problem, and want show admin bar for log in an log out users, you must add in CSS the following codec:
@media screen and (max-width:782px) {
#wpadminbar {
display:block;
}
html {
position:absolute;
top:-46px;
}
}
The codec where say html position absolute is for delete noise black bar located in the up side zone.
If you want, you can also show the notification icon (I think it is named budlle notification) into the admin mar, adding the following codec in CSS zone:
/* Show only default top level items */
#wp-toolbar > ul > li {
display: block;
}
I have gone mad to find the solution, but now we have it.
If you dont want show menu in admin bar to the suscriptors, colaborator and authors, you can use the AG CUSTOM ADMIN plugin. It hide them and help you in a clean design. (you can also hide wordpress logo, and so much things…)
Now, I have only a litlle / big problem:
the drop down menu, when I click in the “notification icon” in the admin bar, is not showed correctly… It is showed from the “notification icon” to the right zone, so in mobiles user can red the title of the notification.
The solution is show the dropdown menu from the “notification icon” to the left zone. So, also in mobiles users can red the title of the notification.
Can you help me for to make that?
I have helped you, now I hope someone can help me 😉
Thank for your support and have funny
Hi Earl,
Two things you can do:
- Hide admin user from members list. This post has some answers:- https://buddypress.org/support/topic/hide-admin-from-members-and-activity/
- Change the user_nicename field in users table in database, for the admin user.
I suggest going with the first option.
Please put this code in your bp-custom.php
function buddydev_hide_members_directory_from_all_except_admin() {
if ( bp_is_members_directory() && ! is_super_admin() ) {
//should we add a message too?
//bp_core_add_message( 'Private page.', 'error' );
bp_core_redirect( site_url('/') );
}
}
add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );
That should do it. Hoe it helps.