Login::redirect_auth_pages_to_account()
Summary
Redirect the login/registration pages to the account page for logged in users.
Return
(void)
Source
File: src/BigCommerce/Accounts/Login.php
public function redirect_auth_pages_to_account() { if ( ! is_singular() || ! is_user_logged_in() ) { return; } $page = get_queried_object_id(); $auth_pages = array_filter( [ get_option( Login_Page::NAME, 0 ), get_option( Registration_Page::NAME, 0 ), ] ); if ( in_array( $page, $auth_pages ) ) { $account_page = get_option( Account_Page::NAME, 0 ); $url = $account_page ? get_permalink( $account_page ) : home_url( '/' ); /** * Filter the URL to the account profile page * * @param string $url The account profile page URL */ $url = apply_filters( 'bigcommerce/account/profile/permalink', $url ); // Go to default WP login page if it's a confirm email action. $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING ); if ( $action === 'confirm_admin_email' ) { remove_filter( 'login_url', bigcommerce()->accounts->login_url, 10 ); $url = add_query_arg( [ 'action' => $action, 'wp_lang' => filter_input( INPUT_GET, 'wp_lang', FILTER_SANITIZE_STRING ), ], wp_login_url( $url ) ); } wp_safe_redirect( esc_url_raw( $url ) ); exit(); } }