Question

I want to redirect users to account details after registering, by default it is redirecting to my account dashboard.

This is where I want users to be redirected

mydomain.com/my-account/edit-account/

I found something like this, but I think it won't work

function iconic_register_redirect( $redirect ) {
    return wc_get_page_permalink( '' );
}

add_filter( 'woocommerce_registration_redirect', 'iconic_register_redirect' );
Was it helpful?

Solution

To get "Account details" permalink (endpoint edit-account) you need to use function wc_get_account_endpoint_url.

function wc_redirect_to_account_details( $redirect ) {
    $redirect = wc_get_account_endpoint_url('edit-account');
    return $redirect;
}
add_filter( 'woocommerce_registration_redirect', 'wc_redirect_to_account_details' );

OTHER TIPS

function woo_login_redirect( $redirect, $user ) {
$redirect_page_id = url_to_postid( $redirect );
$checkout_page_id = wc_get_page_id( 'checkout' );

if( $redirect_page_id == $checkout_page_id ) {
    return $redirect;
}

return wc_get_page_permalink( 'shop' );
}
add_filter( 'woocommerce_login_redirect', 'woo_login_redirect' );

Use this function to redirect users after login

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top