is_account_page()的WooCommerce条件,但仅登录部分 [英] WooCommerce condition for is_account_page(), but only the login portion

查看:70
本文介绍了is_account_page()的WooCommerce条件,但仅登录部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试用户是否在帐户页面上,但仅用于登录部分作为标题状态...

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?

推荐答案

可能需要结合!is_user_logged_in() is_account_page(),方法是:

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
}

还有2个有用的钩子:

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 
}; 

这篇关于is_account_page()的WooCommerce条件,但仅登录部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆