This shortcode is used to check user login status and conditionally execute the block based on it. aw2_if_logged_in shortcode can also execute based on user role or username.

aw2_if_logged_in is one shortcode that allows you conditionally check/test modules before making it live for everyone.

  • main:
    yes | no

    Set ‘yes’ to indicate that wrapped block needs to be executed if user is logged in. Set it to ‘No’ for executing a block if user is not logged in. By default it is set to ‘yes’

  • role:
    admin | superadmin | or any other custom role or capability

    If role attribute is specified, then it checks for role of the user as well. you can use ‘admin’ to indicate administrator role(ie with capability manage_options), ‘superadmin’ to indicated superadmin role in multi-site setup of WordPress.

    You can also specify any other role that is active with your WordPress environment.

    You can also you test for capability of a logged in user with ‘role’ attribute.

  • user_login:
    username of a user

    If you specify username of a user with user_login, you can run a code block specifically for that user.

Examples of using aw2_if_logged_in:

Using role

Executing a block based on username

Executing a block based on capability