Hi, is there any way I can trigger the log-in sidebar when a user clicks on a page if he’s not logged in?
For example, I need a user who clicks a button or a nav menu to open the log-in sidebar only if he’s not logged in. If he/she is logged in then when he clicks the button it just goes to the desired page.
I tried doing it by using this custom_redirects:
function custom_redirects() {
$redirecturl = site_url().’/My-account’;
if ( is_page( ‘vinde-sneakers’ ) && !is_user_logged_in() ) {
wp_redirect( $redirecturl );
die;
}
}
add_action( ‘template_redirect’, ‘custom_redirects’ );
This works but the problem is that I am not using the Woocommerce registration fields, I have removed them and I am now only using the WCFM registration form for registering new users, so my Account page doesn’t have any registration form on it…. they are separate. That’s why I need to trigger the log-in pop-up/sidebar(because it has both log-in and create an account button that redirects to the registration form page) for this to make sense for my users. Could you please help?
Sorry to say but right now there is no option in Theme Settings available for that. It requires Customization and this is beyond our limitations and support policy scope.
Open via the custom log-in sidebar, this is possible only with JS, for this, you need to call this code when you need to open the form, otherwise, unfortunately, no way.