WOOCommerce redirect after registration to account details
-
05-05-2021 - |
문제
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' );
해결책
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' );
다른 팁
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
제휴하지 않습니다 wordpress.stackexchange