Add Tab Based On DISPLAYED User Not LOGGED IN User
-
I can use the code below to make a tab which will show to the logged in user if their role is NOT one of the roles customer, owner, renter or admin.
But what I need, is for EVERYONE to see the tab if it’s added, but for it just not to be added unless you’re a certain role. IE add it if your not one of the listed roles.
So it should be based on the role of the DISPLAYED user not the LOGGED IN user, if you see what I mean….
So what I already have below is:
Role A DOES have tab on their profile & CAN see it on other roles/profiles who also do.
Role B DOES NOT have tab, and CANNOT see it on roles who do (which is not what I need)But what I need is (very close to that but not quite…):
Role A DOES have tab on their profile & CAN see it on other roles/profiles who also do.
Role B DOES NOT have tab, and CAN ALSO see it on any roles who do.How do I amend the below to make that work? I’ve looked for hours for an example and tried all sorts of things I’d have thought should work but I’m getting something wrong, although it seems to me quite simple an idea I can’t find anything similar or make it work. Here’s the code I’ve got:
function um_mycustomtab_add_tab( $tabs ) { $hide_from_roles = array( 'um_customer','um_owner','um_renter','administrator' ); if ( is_user_logged_in() && ! in_array( um_user('role') , $hide_from_roles ) ) { $tabs[ 'places' ] = array( 'name' => 'Places', 'icon' => 'um-faicon-map-icon', 'default_privacy' => 0, ); } UM()->options()->options[ 'profile_tab_' . 'places' ] = true; return $tabs; } add_filter( 'um_profile_tabs', 'um_mycustomtab_add_tab', 1000 );
There was a plugin called Ultimate Member Profile Tabs but it’s not in date now and doesn’t work properly any more. You’re kind of using this functionality in the posts tab and about tab etc, however there’s no option to deal with it based on PROFILE DISPLAYED rather than profile of user that’s looked / logged in.
All ideas gratefully received
Thank you very much
- The topic ‘Add Tab Based On DISPLAYED User Not LOGGED IN User’ is closed to new replies.