@vince_
11 years, 5 months ago
I’ve got it … It wasn’t in the right order … I feel stupid
add_action( ‘init’, ‘my_em_setup_nav’ );
function my_em_setup_nav(){ global $bp; $args = array( ‘field’ => ‘Role’, ‘user_id’ => bp_loggedin_user_id() ); $role = bp_get_profile_field_data($args); if( $role == “Role1” ){ bp_core_remove_subnav_item(‘events’,’my-events’); bp_core_remove_subnav_item(‘events’,’my-locations’); bp_core_remove_subnav_item(‘events’,’my-bookings’); } }
no sorry, it returns the right number
bp_loggedin_user_id() returns 0
It’s not working, here is my entire code (without the “if” condition it’s working) :
$args = array( 'field' => 'Role', 'user_id' => bp_loggedin_user_id() ); $role = bp_get_profile_field_data($args); add_action( 'init', 'my_em_setup_nav' ); function my_em_setup_nav(){ global $bp; if( $role == "Role1" ){ bp_core_remove_subnav_item('events','my-events'); bp_core_remove_subnav_item('events','my-locations'); bp_core_remove_subnav_item('events','my-bookings'); } }
Hi,
No, it’s not working. My 2 other techniques work in other pages but not in functions.php. Does this file have something special ?
Thanks