2

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?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
corporalpoon
  • 219
  • 6
  • 16

1 Answers1

7

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 
}; 
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399