How can I remove the “send invites” button. Group members do not have option to invite so there should be no button.
@andrew_long15
use this code.
/**
* Removes send invite tab according to Group Invitations setting.
*
* @since 2.2.0
*/
function remove_send_invite_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(
‘send-invites’ => 1,
);
$parent_nav_slug = bp_get_current_group_slug();
$current_group_id = bp_get_current_group_id();
$invite_status = groups_get_groupmeta( $current_group_id, ‘invite_status’, true );
if ( ‘admins’ === $invite_status || ‘mods’ === $invite_status ) {
// 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’, ‘remove_send_invite_tab’, 9 );
@andrew_long15
@anonymized-16480907
Hello
I tried to paste the code in the code snippets plugin, but the “select members” feature still show in the “Send Invitation” tab of the group.
is it possible any specific explaination.
thank you
@andrew_long15 , you can simply add this to remove the invites tab from all the groups.
add_filter( ‘bp_groups_user_can_send_invites’, ‘__return_false’ );