WooCommerce is_account_page() Function: Examples [Guide]

WooCommerce is_account_page function guide with a user profile icon

Customers spend time on the My Account page to check orders, update addresses, and manage subscriptions. Store owners often want to style that area, load tools for it, or change how it looks, without affecting the rest of the site.

The woocommerce is_account_page function, written as is_account_page(), checks whether the current request is the My Account page. This guide covers what it matches, the logged-out case that surprises many developers, and two examples you can use.

What is_account_page() Checks

is_account_page() is a WooCommerce conditional tag. It returns true when the request shows the My Account page you set in WooCommerce settings, under the Advanced tab, Page setup section.

The account endpoints, such as orders, downloads, and edit-account, live on the same page. The function returns true on those too. To check one endpoint, use is_wc_endpoint_url() with the endpoint name.

Syntax and Return Value

  • Arguments: none.
  • Return value: true on the My Account page and its endpoints, otherwise false.
  • Where to use it: inside hooks that run after the main query is set up.

Logged-In and Logged-Out Visitors

The function does not check login status. A logged-out visitor who opens the My Account page sees the login and registration forms, and is_account_page() still returns true. If your code should only apply to logged-in customers, add is_user_logged_in() to the check.

When to Call is_account_page()

Like the other page checks, is_account_page() depends on the main query. Calling it in init or at file load returns false. Use one of these hooks:

  • wp fires after the main query is ready.
  • wp_enqueue_scripts fires while the page head is built, which suits assets.
  • body_class fires when the body tag is printed, which suits CSS classes.

Tip: If the rule should apply to logged-in customers only, combine the checks in one line: is_account_page() && is_user_logged_in(). Writing it with the escaped ampersands keeps the code valid HTML when you paste it into the editor.

Example 1: Add a Body Class to the Account Area

Body classes give you a clean hook for styling the account pages. This filter adds a class only on the My Account page, so one stylesheet can change the account layout without affecting the shop.

<?php

add_filter( 'body_class', 'my_account_body_class' );

function my_account_body_class( $classes ) {
    if ( is_account_page() ) {
        $classes[] = 'my-account-custom';
    }

    return $classes;
}

Target the class in CSS, for example .my-account-custom .woocommerce-MyAccount-navigation, to adjust the menu on the account pages.

Example 2: Load an Account-Only Stylesheet

Some customizations need their own file. This example enqueues a stylesheet only on the My Account page, which keeps the file out of the shop and checkout.

<?php

add_action( 'wp_enqueue_scripts', 'my_enqueue_account_styles' );

function my_enqueue_account_styles() {
    if ( ! is_account_page() ) {
        return;
    }

    wp_enqueue_style(
        'my-account-styles',
        get_stylesheet_directory_uri() . '/css/account.css',
        array(),
        '1.0.0'
    );
}

Replace the path with your own file. Place the code in a child theme’s functions.php file or in a small site plugin, so it survives theme updates.

Common Mistakes

  • Assuming it means logged in. The login form lives on the same page, so logged-out visitors get true. Add is_user_logged_in() when needed.
  • Calling it too early. A check in init or at file load returns false. Move the call into a hook that runs after wp.
  • Matching the slug. is_page( 'my-account' ) breaks after a slug change. The function uses the page ID that WooCommerce stores.
  • Checking one endpoint with the wrong tag. Use is_wc_endpoint_url( 'orders' ) when the rule applies to one section only.

Account rules often connect with checkout, because customers move between the two. Read the guide on is_checkout() for the checkout side. For the page customers see after an order, see the guide on the order received page. The other page checks are covered in the guides on is_cart(), is_shop(), and is_product().

FAQs About is_account_page()

Does is_account_page() return true only for logged-in users?

No. It checks the page, not the login state. Logged-out visitors who open the My Account page also get true. Add is_user_logged_in() if your rule needs a logged-in customer.

Does is_account_page() work on account endpoints such as orders?

Yes. The endpoints are part of the My Account page, so the function returns true on them. To target a single endpoint, use is_wc_endpoint_url().

Why does is_account_page() return false on my custom account page?

The page is not set as the My Account page in WooCommerce settings. Set it there, then clear your caches and check again.

Can I call is_account_page() in functions.php?

You can call it inside a hook that runs after the main query is ready, such as wp or wp_enqueue_scripts. A direct call at file load returns false.

Conclusion

is_account_page() gives you a clean check for the My Account area. Use it inside wp, wp_enqueue_scripts, or body_class, and add a login check when the rule is only for customers.

If you need account pages customized for your store, hire a WooCommerce developer or send your requirements through the application form.

About The Author

Picture of Andriy Haydash

Andriy Haydash

Andriy Haydash is a WordPress Expert who helps people build and launch successful WordPress membership and e-learning websites.

Note: Not all of the articles are written directly by me.
Affiliate Disclaimer: Some links in the post may be my affiliate links

Kinsta - Managed Hosting for WordPress

Before YOU Leave...
Join My Newsletter

Get practical tips & tricks on how to start, grow and market your course/membership site.