Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to redirect to a custom page url if non logged in user clicks on a profile

@kpkreative

Participant

Hi Michael,

Thank you so much for sharing the code for the redirect and the great source.

There must be something on my website that is conflicting as I’ve added the code and the redirect still goes to the homepage rather than the custom link.

I want the non logged in user to still see the directory, though not the single profiles, so I referenced the page below in the code

My code is as follows:
function ps_guest_redirect() {
global $bp;
if ( bp_is_user() ) {
if(!is_user_logged_in() and !bp_is_register_page() and !bp_is_activation_page() and !is_page(‘member-directory’)) {
wp_redirect(‘https://websiteurl/content-restricted’);
exit;
}
}
}
add_filter( ‘get_header’,’ps_guest_redirect’,1);

Skip to toolbar