Hi i’m really sorry,
now i have 2 questions.
(Similar case to the previous problem with a bit of repeating to make things clearer)
Question 1 :
I have a ‘unit_promo’ tab to display for anyone, except for the agent role.
What I have done:
1. Set the profile/user page so that anyone can access it.
(Page where profile shortcode is stored)
2. Set the ‘unit_promo’ tab on Ultimate Member > Settings > Appearance > Profile Menu, so that anyone can access it.
To prevent the agent role from seeing the ‘unit_promo’ tab either has logged in or not, I customized the code provided from @missveronicatv but it didn’t work.
(For the previous case the code works)
Can you see what I’ve missed?
Here’s the code :
add_filter( 'um_user_profile_tabs', 'um_unit_promo_show_tabs', 6, 1 );
function um_unit_promo_show_tabs( $tabs ){
if( !is_user_logged_in()&& "agent" == um_user('role')) {
$user_id = get_current_user_id();
um_fetch_user( $user_id );
unset( $tabs['unit_promo'] );
return $tabs;
}
$user_id = get_current_user_id();
um_fetch_user( $user_id );
if( "agent" == um_user('role') ){
unset( $tabs['unit_promo'] );
}
return $tabs;
}
Question 2 :
How to adapt code to different conditions
(more than one role).
Example :
add_filter( 'um_user_profile_tabs', 'um_121721_show_tabs', 6, 1 );
function um_121721_show_tabs( $tabs ){
if( !is_user_logged_in()) {
unset( $tabs['uo_learndash_certificates'] );
return $tabs;
}
$user_id = get_current_user_id();
um_fetch_user( $user_id );
if( "partner" || "subscriber" || "customer" == um_user('role') ){
unset( $tabs['uo_learndash_certificates'] );
}
return $tabs;
}
Please help me again,
Really really Thank You
-
This reply was modified 3 years, 2 months ago by
carloz san.