ARMember provides very helpful conditional shortcodes.
All Conditional Shortcodes can be used with “arm_if” and “armNotif” shortcode.
[armif] .. [/armif] and [armNotif] .. [/armNotif]
Show / Hide specific content to specific member by using WordPress built-in conditional tags
. Sometimes itโs necessary to allow everyone to access to your content ( e.g. everyone can land on a certain Post or Page and view it ), but maybe you need to hide ( protect ) a certain part of that content. Or, maybe you need to display something different to non-members.
Check List of available conditional shortcodes:
is_blog_index
This will check whether the current page is blog posts index page or not and according to that content will be shown.
example
[armif is_blog_index()] Content Goes Here [/armif]
[armNotif is_blog_index()] Content Goes Here [/armNotif]
is_home_page
This will be used to show content only if the current page/post is Home page.
example
[armif is_home_page()] Content Goes Here [/armif]
[armNotif is_home_page()] Content Goes Here [/armNotif]
is_single_post
This conditional tag can be used to display content only for the single posts (if the current post is post view/detail page). You can pass post parameter to indicate specific post type.
example
[armif is_single_post()] Content Goes Here [/armif]
[armNotif is_single_post()] Content Goes Here [/armNotif]
is_sticky_post
Checks if the current post is a Sticky Post meaning the “Stick this post to the front page” check box has been checked for the post, content between shortcode will be executed.
example
[armif is_sticky_post()] Content Goes Here [/armif]
[armNotif is_sticky_post()] Content Goes Here [/armNotif]
is_post_type_archive
This conditional tag will check if the query is for an archive page of a given post type(s).
example
[armif is_post_type_archive()] Content Goes Here [/armif]
[armNotif is_post_type_archive()] Content Goes Here [/armNotif]
is_page
This conditional tag can be used to show the content for any single page. This tag must be used BEFORE The Loop and as it does not work inside The Loop.
example
[armif is_page()] Content Goes Here [/armif]
[armNotif is_page()] Content Goes Here [/armNotif]
is_category
This tag will check if a Category archive page is being displayed. According to that you can add content to be displayed in page.
example
[armif is_category()] Content Goes Here [/armif]
[armNotif is_category()] Content Goes Here [/armNotif]
is_tag
This will check if a Tag archive page is being displayed.According to that you can add content to be displayed in page.
example
[armif is_tag()] Content Goes Here [/armif]
[armNotif is_tag()] Content Goes Here [/armNotif]
has_tag
This conditional tag will check if the current post has any of the given tags passed in parameter. The given tags are checked against the post’s tags term_ids, names and slugs. Tags given as integers will only be checked against the post’s tags term_ids.
example
[armif has_tag()] Content Goes Here [/armif]
[armNotif has_tag()] Content Goes Here [/armNotif]
is_taxonomy
Checks if a custom taxonomy archive page is being displayed, then content between shortcode will be executed. If the $taxonomy parameter is specified, this function will additionally check if the query is for that specific taxonomy. Note that is_tax() returns false on category archives and tag archives.
example
[armif is_taxonomy()] Content Goes Here [/armif]
[armNotif is_taxonomy()] Content Goes Here [/armNotif]
author_archive
Checks if an Author archive page is being displayed, then content between shortcode will be executed.
example
[armif author_archive()] Content Goes Here [/armif]
[armNotif author_archive()] Content Goes Here [/armNotif]
is_archive
This tag will check if any type of Archive page is being displayed. An Archive is a Category, Tag, Author or a Date based pages.
example
[armif is_archive()] Content Goes Here [/armif]
[armNotif is_archive()] Content Goes Here [/armNotif]
is_search
This conditional tag can be used to check if search result page archive is being displayed. If you want to show/hide content in accordance with search page than this tag will be useful.
example
[armif is_search()] Content Goes Here [/armif]
[armNotif is_search()] Content Goes Here [/armNotif]
is_rtl
This conditional tag will checks if current locale is RTL (Right To Left script).
example
[armif is_rtl()] Content Goes Here [/armif]
[armNotif is_rtl()] Content Goes Here [/armNotif]
is_multisite
This tag will be used to determine whether Multisite support is enabled or not. So you can show/hide content in accordance with multisite.
example
[armif is_multisite()] Content Goes Here [/armif]
[armNotif is_multisite()] Content Goes Here [/armNotif]
is_main_site
Check if site is main site of the network from the given site id passed in parameter. Yo can show/hide content for that specific site.
example
[armif is_main_site()] Content Goes Here [/armif]
[armNotif is_main_site()] Content Goes Here [/armNotif]
has_post_thumbnail
This tag will check if a post has a Featured Image (formerly known as Post Thumbnail) attached or not. So, you can show content conditionally when there is a featured image set for the post.
example
[armif has_post_thumbnail()] Content Goes Here [/armif]
[armNotif has_post_thumbnail()] Content Goes Here [/armNotif]
is_user_can
Checks if a user has capability or role, then content between shortcode will be executed. Similar to current_user_can(), but this function takes a user ID or object as its first parameter.
example
[armif is_user_can()] Content Goes Here [/armif]
[armNotif is_user_can()] Content Goes Here [/armNotif]
current_user_can
This conditional tag will check whether current user has particular capability/role or not. Based on that you can show/hide content to user.
example
[armif current_user_can()] Content Goes Here [/armif]
[armNotif current_user_can()] Content Goes Here [/armNotif]
current_user_can_for_blog
This will check whether current user has a capability or role for a given blog or not. You can pass blog ID as parameter to check if the current user has a capability for another blog on the network.
example
[armif current_user_can_for_blog()] Content Goes Here [/armif]
[armNotif current_user_can_for_blog()] Content Goes Here [/armNotif]
check_user_meta
This will check whether current user has correct meta_value based on operator passed as parameter. This will be useful when you want to display data only for those users, who are having some specific value in their user meta.
Default operator is EQUALSTO_N.S = String Comparison
N = Numeric Comparison
Last argument $user_id
is optional argument, if you will not pass any user id then it will check for current user.
check_user_meta($meta_key,$value,"EQUALSTO_S",$user_id)
check_user_meta($meta_key,$value,"EQUALSTO_N",$user_id)
check_user_meta($meta_key,$value,"NOTEQUALSTO_S",$user_id)
check_user_meta($meta_key,$value,"NOTEQUALSTO_N",$user_id)
check_user_meta($meta_key,$value,"GREATERTHAN",$user_id)
check_user_meta($meta_key,$value,"LESSTHAN",$user_id)
check_user_meta($meta_key,$value,"GREATERTHANEQUALSTO",$user_id)
check_user_meta($meta_key,$value,"LESSTHANEQUALSTO",$user_id)
example
[armif check_user_meta('nickname','john','EQUALSTO_S')]Content Goes Here[/armif]
//Will display content if current logged in user's Nickname is john.
$meta_key
Place any user meta key to check whether user has correct meta_value for like user_login, user_email.
$value
Place specific value to compare with user meta key value.
is_user_id
Checks if current user id matches specified id, then content between shortcode will be executed. This shortcode will not work if ID
is not passed.
example
[armif is_user_id()] Content Goes Here [/armif]
[armNotif is_user_id()] Content Goes Here [/armNotif]
is_username
Checks if current user name matches specified name, then content between shortcode will be executed. This shortcode will not work if Name
is not passed.
example
[armif is_username()] Content Goes Here [/armif]
[armNotif is_username()] Content Goes Here [/armNotif]