Login redirect user to the previous URL in WooCommerce

Login redirect user to the previous URL in WooCommerce on your child site.

Snippet Type

Execute on Child Sites

Snippet

add_action( 'woocommerce_login_form_end', 'wc_actual_referrer' );
 
function wc_actual_referrer() {
   if ( ! wc_get_raw_referer() ) return;
   echo '<input type="hidden" name="redirect" value="' . wp_validate_redirect( wc_get_raw_referer(), wc_get_page_permalink( 'myaccount' ) ) . '" />';
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.