• Resolved Suika

    (@suikalum)


    Hello,

    I have two User Roles (Company and Member) and only one of them (Company) has access to adding posts. So it wouldn’t make sense to display the Posts tab on the Members’ profile page.

    The setting UM have right now applies only to show/hide tabs depending on the current logged in user role, and not by which user role is being displayed on the profile page.

    I hope that made sense. Looking for the hook I could add validation to, or even template I could change for this to happen but no luck so far.

    Thanks!

    • This topic was modified 7 years, 2 months ago by Suika.
Viewing 1 replies (of 1 total)
  • Thread Starter Suika

    (@suikalum)

    So I found the solution based on one of UM’s gists.. This one in particular: https://gist.github.com/ultimatemember/643cd90967e5e415378d which shows an example of how to add a custom profile tab.

    Using the um_profile_tabs filter, I added a user role validation via a custom function like this:

    add_filter('um_profile_tabs', 'remove_posts_tab_for_members', 1000 );
    function remove_posts_tab_for_members( $tabs ) {
    
    	global $ultimatemember;
    	
    	// Check if user role is not "Company"
    	if ($ultimatemember->user->get_role() != 'company') {
    		unset($tabs['posts']);
    	}
    
    	return $tabs;
    }

    Hope this helps if anyone has the same problem! ?? For the unfamiliar, this goes in your theme’s function.php file.

    • This reply was modified 7 years, 2 months ago by Suika.
Viewing 1 replies (of 1 total)
  • The topic ‘Disable Tab for Specific User Role’ is closed to new replies.