## woocommerce offtopic – Shortcode inside a redirect

Question

We are trying to connect the database users of wordpress and another website, me manage to synchronize the login and register using an OpenID Connect plugin, but we want for the user to be redirected to another url when he is not logged in before checkout on woocommerce, so we placed this code on functions:

add_action('template_redirect','check_if_logged_in');
function check_if_logged_in()
{
$pageid = get_option( 'woocommerce_checkout_page_id' ); if(!is_user_logged_in() && is_page($pageid))
{
wp_redirect( 'https://anotherwebsite.com' );
exit();
}
if(is_user_logged_in())
{
if(is_page(get_option( 'woocommerce_myaccount_page_id' )))
{

$redirect =$_GET['redirect_to'];
if (isset($redirect)) { echo '<script>window.location.href = "'.$redirect.'";</script>';
}

}
}
}


but OpenID Connect uses a shortcode to generate a dynamic url to sent to the user to log in or register: [openid_connect_generic_auth_url]. Is there a way to insert the shortcode inside the wp_redirect( ‘https://anotherwebsite.com’ ); to make it happen?

0
2 weeks 2022-11-15T18:17:41-05:00 0 Answers 0 views 0