I think an easier way around this would be for you to use a membership plugin, and restrict the content on the 3rd tab. With BB, I think we can hide it with CSS but that can easily be worked around. Using a membership plugin won’t necessarily remove the 3rd tab, but at least the content will only be visible by the said custom role. There should be a lot of free membership plugins out there. Give it a shot and let us know if it works for you!
We can add an extra class to the body tag where it reflects the role. We can also do the same to the Tabs module. Once that is done, we can then target the 3rd tab of that specific module when that specific role is logged in. The code below adds the class to the body tag. This goes to your child theme’s function.php file.
function add_role_to_body($classes) {
$current_user = new WP_User(get_current_user_id());
$user_role = array_shift($current_user->roles);
if (is_admin()) {
$classes .= 'role-'. $user_role;
} else {
$classes[] = 'role-'. $user_role;
}
return $classes;
}
if ( is_user_logged_in() ) {
add_filter('body_class','add_role_to_body');
add_filter('admin_body_class','add_role_to_body');
}
You can add an extra class to the module under the Advanced module. Say for example, if the class you added is fl-tabs-restrict-content, the CSS code below will hide the 3rd tab.
Thanks for the fast response… I will check this out and think how I want to implement this.
I appreciate the code example and hope it also will help someone else.
No worries at all! Just pointing out again that the CSS method is pretty easy to bypass. If you’re trying to hide sensitive information, I’d suggest using the memberships plugin.