Update: I have tried this: https://rocketgeek.com/plugins/wp-members/docs/api-functions/wpmem_redirect_to_login/
But the wpmem_redirect_to_login() function only works when I’m logged in. Do you know how that would be possible? When I test it in an incognito window as a logged-out user, with no caching plugins activated, it simply ignores this redirect function:
function woo_template_redirect(){
if( is_product()) ) {
// echo 'test';
wpmem_redirect_to_login();
}
}
add_action( 'template_redirect', 'woo_template_redirect' );
I have confirmed that a login page has been set in the WP-Members Settings page. I also tried adding a priority to the add_action, like 99 or 50 or 10… no change.
However, it DOES work if I use the native wp_redirect() function like this:
function woo_template_redirect(){
if( is_product()) ) {
$redirect_page = get_site_url(null, '/login/', 'https');
wp_redirect( $redirect_page );
exit();
}
}
add_action( 'template_redirect', 'woo_template_redirect' );
Do you know why it may not work? Thanks!
-
This reply was modified 3 years, 5 months ago by LS.
-
This reply was modified 3 years, 5 months ago by LS.