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.
example
[armif is_blog_index()] Content Goes Here [/armif]
[armNotif is_blog_index()] Content Goes Here [/armNotif]
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.
is_home_page
This will be used to show content only if the current page/post is Home page.
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.
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.
is_post_type_archive
This conditional tag will check if the query is for an archive page of a given post type(s).
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.
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.
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.
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.
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.
author_archive
Checks if an Author archive page is being displayed, then content between shortcode will be executed.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.