Replies
Thanks for the clarification, Brajesh.
Since, in my case, only site admin can activate plugins, I created this reusable function in my BuddyPress hooks plugin:function custom_is_my_site_admin(){ current_user_can('activate_plugins'); }
Seems to work… I couldn’t figure out a better way.
- This reply was modified 8 years, 4 months ago by Javier.
May not be the most elegant solution, but here’s what I came up with:
function my_remove_profile_tabs() { if ( current_user_can( 'activate_plugins' ) ) { return; } bp_core_remove_subnav_item( 'settings', 'account-admin-visibility-mode' ); } add_action( 'bp_init', 'my_remove_profile_tabs' );
Also, do you guys know how to remove items from account menu (top right dropdown)?
I couldn’t find ‘bp_core_remove_nav_item/bp_core_remove_nav_item’ equivalent. I know CSS can always come to the rescue, but there must be something specific.Thanks,
Javier- This reply was modified 8 years, 4 months ago by Javier.
Hello again,
I’ve been able to remove the options doing the following (which makes not necessary to overload ‘groups/single/admin.php’ template, I guess):
function jatstudio_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-settings’ => 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, ‘groups’ );
}// You may want to be sure the user can’t access
if ( ! empty( $hide_tabs[ bp_action_variable( 0 ) ] ) ) {
bp_core_add_message( ‘No tienes suficientes permisos para acceder.’, ‘error’ );
bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );
}
}
add_action( ‘bp_actions’, ‘jatstudio_remove_group_admin_tab’, 9 );The key is to add $component to ‘bp_core_remove_subnav_item()’, which defaults to ‘members’.
My problem now is that I also need to remove ‘send-invites’ from groups primary navigation. The function is ‘bp_core_remove_nav_item()’ I guess, but this is not working:
bp_core_remove_nav_item( ‘send-invites’, ‘groups’ );
It would be nice to remove all of this options from users dropdown menu too.
Thank you,
JavierHi Brajesh,
Thank you very much for the guidance.
I was able to hide privacy options within mytheme/buddypress/groups/single/admin.php, so now ‘mygroup/admin/group-settings/’ is empty for non super admin. But the tab is still there, and I’d like to remove ‘delete-group’ also. Tried this (in a plugin) with no luck:
function test_remove_group_admin_tab() {
global $bp;
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
// other admin subnav items are: group-settings, group-avatar, group-invites, manage-members
$hide_tabs = array(
‘group-settings’ => 1,
‘delete-group’ => 1
);
// since BP 2.2
$slug = bp_get_current_group_slug() . ‘_manage’;// Remove the nav item
foreach ( array_keys( $hide_tabs ) as $tab ) {
bp_core_remove_subnav_item( $slug, $tab );
}
}
add_action( ‘bp_groups_setup_nav’, ‘test_remove_group_admin_tab’, 9 );I read somewhere there are certain issues with bp_core_remove_subnav_item() and other navigation removal functions. I don’t really know what’s happening here.
Thanks
JavierHello,
Finally I could not sync last name with users registered before “BP XProfile WordPress User Sync”: you have to update user’s data in order to make plugin work.
So my advice here is to install the plugin before adding users (especially if you are going to add a fairly amount, which was my case).Hi Ravi,
I’m testing your code, but can’t see any change.
I guess my question is confusing, I’ll try to clarify: if you register an user (from wp-admin/wp-users.php) there are Username (stored in wp_users db table), First Name and Last Name (both stored in wp_usermeta). My guess is that BuddyPress “syncs” ‘First Name’ with an extended profile field called ‘Name’; but does nothing with ‘Last Name’.Thank you
Javier