WooCommerce condition for is_account_page(), but only the login portion

﹥>﹥吖頭↗ 提交于 2020-12-13 04:14:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!