• Resolved othmaneerraih

    (@othmaneerraih)


    Hello,

    I hope you’re doing well.

    I recently added a plugin that forces user to login before checkout.
    I am using Ultimate Member plugin.
    I also added this code, that makes them go to checkout after signing in / up, But is doesn’t work if they sign in/up using google or facebook, ie through the Super Socializer plugin.

    add_action('template_redirect','um_122021_check_if_logged_in');
    function um_122021_check_if_logged_in()
    {
        $pageid = get_option( 'woocommerce_checkout_page_id' );// your checkout page id
        if( ! is_user_logged_in() && is_page( $pageid ) && function_exists('um_get_core_page') )
        {
            $url = add_query_arg(
                'redirect_to',
                get_permalink($pageid),
                um_get_core_page("register")
            );
            wp_redirect( $url );
            exit;
        }
    }

    Can you please help me fix it ? I want to redirect them to checkout if they are redirected to login after trying to go to checkout. But I don’t want to redirect them if they are loggin in normally.

    Best regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Heateor Support

    (@heateor)

    Hi,

    I am doing good, thanks ??

    >>>I also added this code, that makes them go to checkout after signing in / up, But is doesn’t work if they sign in/up using google or facebook, ie through the Super Socializer plugin.
    The code you have posted, checks if a user is not logged into the site before redirecting them.

    Usually, there is a redirect_to parameter in the URL when someone lands on the login, register pages and it has the URL of the web page that was being visited right before landing on the login, register pages. Plugin checks for this parameter and redirects users to the same after social login, if it’s there.

    Thread Starter othmaneerraih

    (@othmaneerraih)

    I don’t understand what I am supposed to do. What should I do to fix this please?

    Plugin Author Heateor Support

    (@heateor)

    If you want to control the redirection after social login, you can use the Login redirection and Registration Redirection options in the Advanced Configuration section at the Super Socializer > Social Login options page in the admin area.

    Thread Starter othmaneerraih

    (@othmaneerraih)

    I just had to choose redirect to same page befor login in, thank you.

    Plugin Author Heateor Support

    (@heateor)

    No problem. May I ask you to leave a review?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect to checkout afte Sign in / Sign up’ is closed to new replies.