BuddyDev

Search

If you are using BuddyPress Profile visibiliy manager plugin, the plugin allows users to set their profile to various privacy levels.

If a user does not meet the visibility requirement and tries to visit other user’s profile, he gets redirected to the referrer page(last page from where he clicked the link). If the referrer page is empty, he will be redirected to the home page of the site. Additionally,  a notice message is added via BuddyPress bp_core_add_message to notify the users of the privacy limitation.

In case you want to redirect the user to a specific page when they do not meet the visibility requirement, you can filter on  ‘bp_profile_visibility_redirect_location‘.

Usage:-

where “your_function_name” is the name of the function to be called. The function is passed 2 arguments in the following order:-

  • $location:- the location where the visitor will be redirected if you do not modify it
  • $privacy:- one of the privacy levels,. Possible values are (‘public’, ‘friends’,’self’)

Example 1:- Redirect to a page on site if a user can not access the profile.

Example 2:- Based on privacy level, Redirect to different page when the profile access is denied

You can put these code in your bp-custom.php or in your theme’s functions.php