Hello-
I am working on a site where I want to hide a tab for select user levels. I have that done. I am wondering however if there is a way to show the tab but not the content. For example, I am trying to charge people to see who is veiwing their profile so it would be ideal to show the tab and the number of veiws, but it is not clickable until they upgrade?
Hi Nancy,
Welcome to BuddyDev support forums.Thank you for using the plugin.
I am sorry, at the moment, the plugin does not have any functionality like this.What you are looking for is restricting access to the tab without removing it. If there is one or 2 tabs you want to have this behaviour, Please share the roles and restrictions, Our team will provide you the code.
Regards
BrajeshHello Nancy,
Please try the following code:
add_action( 'bp_template_redirect', function () { // Return if not on user page. if ( ! bp_is_user() ) { return; } // Either user activity page or user friends page need to check access. $needs_access_check = bp_is_user_activity() || bp_is_user_friends(); // If on visitor tab to check accessibility. if ( ! $needs_access_check && bp_is_current_component( 'visitors' ) ) { $needs_access_check = true; } // Return if no need to check user accessibility. if ( ! $needs_access_check ) { return; } // Currently, Logged-in user roles. $user_roles = is_user_logged_in() ? wp_get_current_user()->roles : array(); // Replace editor with your role. $allowed_roles = array( 'administrator', 'editor' ); $has_allowed_roles = array_intersect( $allowed_roles, $user_roles ); // Redirect if not allowed. if ( ! $has_allowed_roles ) { // Provide page in case to redirect to custom page. $redirect_page_id = 0; $redirect_to = empty( $redirect_page_id ) ? bp_displayed_user_domain() : get_permalink( $redirect_page_id ); bp_core_add_message( __( 'You are not allowed to access this page.' ) ); bp_core_redirect( $redirect_to ); } });
You can place is code in ‘bp-custom.php’ file
For more info: https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/
Note: Please make sure that the default user tab is set other than ‘Timeline’, ‘Connections’, and ‘Profile Views’
This is amazing- THANK YOU!
I wonder if this can happen for vistors and connections as well? Right now, it only happens just for timeline?
Please see screenshots where Timeline shows correctly but does not allow access. It would be preferable to have Profile Views and Connections also show but be restricted.
https://www.dropbox.com/s/t6oto6htj3n4lzv/2022-02-21_09-53-21.jpeg?dl=0
https://www.dropbox.com/s/bmciyhifvz43x74/2022-02-21_10-01-24.jpeg?dl=0
THANK YOU AGAIN!
Hi –
I am not understanding what you want me to do? I only have the profile tabs pro installed?
Hello Nancy,
Please try after deactivating the “BuddyPress User Profile Tabs Creator Pro” plugin and then try to access the restricted tab i.e. Timeline, Connections, and Profile Visitors.
You can deactivate the plugin from the Dashboard > Plugins > Installed Plugin page.
Please let me know if it helps or not.
Regards
RaviHi Ravi-
When I turn that plugin off, it makes all of my custom tabs disappear so I need to have it on. The code you gave me DID work, but it only did it for the timeline tab. I was hoping it would do it for the connections tab, the timeline tab, and also the profile views tab. Is this possible by just adding the same code you have for the timeline tab?
Hi Nancy,
Thank you for the reply.Please allow me to look at your issue and get back to you within next 24 hours.
Regards
Brajesh
You must be logged in to reply to this topic.