Answer the question
In order to leave comments, you need to log in
How to open the account editing page instead of the console in woocommerce when entering your personal account?
Good day. When opening the My Account WooCommerce page, the Console ( dashboard.php ) is opened. Is it possible to make it open the edit-account page instead ?
Answer the question
In order to leave comments, you need to log in
By default, when opening the My Account page in WooCommerce, if the user is not authorized, he is prompted to Login / Register. After logging in, the same url remains, the same My Account page, but with personal data - Dashboard (but not the Dashboard of the WordPress admin). The default url is /my-account/, not dashboard.php.
As for redirecting to /my-account/edit-account/, it is done like this:
function woo_login_redirect( $redirect_to ) {
$redirect_to = wc_customer_edit_account_url();
return $redirect_to;
}
add_filter( 'woocommerce_login_redirect', 'woo_login_redirect' );
/**
* Always redirect user to "Edit Account" page after login.
*
* @return string Target URL
*/
function woo_login_redirect()
{
return wc_customer_edit_account_url();
}
add_filter( 'woocommerce_login_redirect', 'woo_login_redirect' );
/**
* Always redirect user to "Edit Account" page after login.
*
* @return string Target URL
*/
add_filter( 'woocommerce_login_redirect', function() {
return wc_customer_edit_account_url();
} );
For example like this:
function new_dashboard_home($username, $user){
if(array_key_exists('administrator', $user->caps)){
wp_redirect(admin_url('admin.php, 'http'), 301);
exit;
}
}
add_action('wp_login', 'new_dashboard_home', 10, 2);
function loginRedirect( $redirect_to, $request, $user ){
if( is_array( $user->roles ) ) {
return "/wp-admin/edit.php?post_type=page";
}
}
add_filter("login_redirect", "loginRedirect", 10, 3);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question