Skip to main content

Set PHP Statement Condition

Steps for specifying PHP statement condition

  1. In the Condition name input area type your chosen name for this condition. If no name is input, by default, when the conditional is saved it will be named the same as the Condition type.

  2. From the Condition status drop down select Active or Inactive as required.

    Beware

    Inactive conditions will always evaluate as TRUE.

  3. From the Condition type drop down select PHP statement.

  4. Within the PHP statement input area define the required PHP conditional statement.

    Any valid PHP conditional function can be used.

    Note

    You can also use any conditional tags including WordPress and WooCommerce conditional tags.

    A list of WordPress Conditional Tags can be found here:

    WordPress Conditional Tags

    A list of WooCommerce Conditional Tags can be found here:

    WooCommerce Conditional Tags

    Here are some examples using WordPress conditional tags:

    a. Statement evaluates as TRUE if the user IS on the home page.

    is_front_page()
    Note

    Any function preceded with an exclamation mark ! specifies the negative use case of the function.

    b. Statement evaluates as TRUE if the user IS NOT on the home page.

    !is_front_page()
    Note

    It is also possible to combine conditions with && (representing AND) and || (representing OR).

    c. Statement evaluates as TRUE if the user IS on the home page AND the home page is the blog page.

    is_front_page() && is_home()

    d. Statement evaluates as TRUE if the user IS on the page titled Members Dashboard OR on the page titled My Account.

    is_page( 'Members Dashboard' ) || is_page( 'My Account' )