Yes, use is_super_admin()
For example:
function add_iuda_tab() {
global $bp;
if ( is_super_admin() ) {
bp_core_new_nav_item( array(
'name' => 'Iuda',
'slug' => 'iuda',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'iuda_screen',
'position' => 200,
'default_subnav_slug' => 'iuda'
) );
}
}
add_action( 'bp_setup_nav', 'add_iuda_tab', 100 );
function iuda_screen() {
add_action( 'bp_template_title', 'iuda_screen_title' );
add_action( 'bp_template_content', 'iuda_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function iuda_screen_title() {
echo 'iuda Title<br/>';
}
function iuda_screen_content() {
echo 'iuda Content<br/>';
}
thank you @shanebp for quick response
this function can be extended for administrator and editor role ?
is_super_admin()
checks to see if the current user is an administrator.
To check if they are an editor, you need to check whether they have an editor permission.
Try:
if ( is_super_admin() || current_user_can('editor') ) {
thank you @shanebp, it work.
One small request if it’s possible: i want, if i click to “Iuda” tab, to send me to wp-admin page.
This is the link https://failtrafic.ro/wp-admin/
sorry but my knowledge in the field of php are at a chicken level 😀
Try:
function iuda_screen_content() {
bp_core_redirect( 'https://failtrafic.ro/wp-admin/' );
}
Try :
wp_redirect( 'https://failtrafic.ro/wp-admin/' ); exit;