I tried to use another way to avoid facebook login in checkout page.
I redirect user to my-account page to login if they not logged in and wanna access cart or checkout page.
When user login using username and password , the filter wp_login is trigger then redirect them to checkout page.
However when user use facebook login , the filter wp_login is not trigger so they enter my_account page which is wrong. I want them to redirect to checkout page.
What filter or action can I use to check if their cart is not empty then redirect them to checkout page after facebook login successfully ?
function wpse_131562_redirect() {
if (
! is_user_logged_in()
&& (is_cart() || is_checkout())
) {
// feel free to customize the following line to suit your needs
wp_redirect(‘/my-account’);
exit;
}
}
add_action(‘template_redirect’, ‘wpse_131562_redirect’);
function woocommerce_custom_redirects() {
ob_start();
if ( WC()->cart->get_cart_contents_count() !== 0 || !WC()->cart->is_empty() ) {
wp_redirect( “/checkout” );
exit;
}
}
add_action(‘wp_login’, ‘woocommerce_custom_redirects’);

















