Thread Starter
8bit7
(@8bit7)
I added the code below to functions.php to try to force it, but it’s still not redirecting.
function add_login_redirect() {
if ( is_page('profile') && !is_user_logged_in() ){
wp_redirect( site_url( '/login' ) );
}
}
add_action('template_redirect', 'add_login_redirect');
Thread Starter
8bit7
(@8bit7)
So, got it working in functions.php, but still would be awesome to have it in the plugin. Here’s the code for future googlers.
// Redirect logged out users who visit the profile page
function login_redirect() {
// Get current page
global $pagenow;
// Check to see if user in not logged in and also on the profile page
if(!is_user_logged_in() && $pagenow = is_page('profile'))
// If user is, redirect to login form.
auth_redirect();
}
add_action( 'wp', 'login_redirect' );
Plugin Contributor
Paolo
(@paoltaia)
The behavior you’re experiencing is expected, but your suggestion has value. I’ll pass your request on to our development team for consideration.
Thanks,