Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Get xprofile field value in functions.php

@henrywright-1

Member

Try putting everything except the add_action( 'init', 'my_em_setup_nav' ); inside the my_em_setup_nav() function. So

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');
	}	
}
add_action( 'init', 'my_em_setup_nav' );
Skip to toolbar