问题
I need to test whether the user is on the account page, but only for the login portion as the title states...
Is there a way to do this?
回答1:
May be you need to combine ! is_user_logged_in() with is_account_page(), this way:
if( ! is_user_logged_in() && is_account_page() ){
// Test something
}
There is also 2 useful hooks:
add_action( 'woocommerce_before_customer_login_form', 'action_woocommerce_before_customer_login_form', 10, 0 );
function testing_login_portion( ) {
// Test something
};
Or maybe more useful for you as it targets the my account login form:
add_action( 'woocommerce_login_form_start', 'action_woocommerce_before_customer_login_form', 10, 0 );
function testing_login_portion( ) {
// Test something
};
来源:https://stackoverflow.com/questions/44861652/woocommerce-condition-for-is-account-page-but-only-the-login-portion