mycred_hide_if
Description
This shortcode allows you to hide parts of your content for those who fulfil the requirements you set. This shortcode is the opposite of the mycred_show_if shortcode. You can set a balance requirement, rank requirement (if the Ranks add-on is enabled) or a reference count.
Available since version 1.7
Shortcode Attributes
Attribute | Type | Required | Default | Description |
---|---|---|---|---|
balance |
int or float | No | -1 | Option to set a balance requirement in order to show the content. Can be combined with other requirements. |
rank |
int or string | No | -1 | Option to set a rank requirement in order to show the content. Can be combined with other requirements. Accepts either the rank post ID or the rank title (case sensitive). |
ref |
string | No | - | Option to set a reference requirement in order to show the content. Can be combined with other requirements. Must be used in combination with the "count" attribute. Together you can choose for example to require a user to have gained points 10 times or more for comments in order to show the content. |
count |
int | No | -1 | Used in combination with the "ref" attribute and defines the number of instances the given reference should return in order for the content to be shown. |
ctype |
string | No | mycred_default | Option to set the point type for requirements. If you have ranks for multiple point types, this all also affect the rank requirement. |
visitors |
string | No | - | Optional text to show to visitors. Only logged in users can qualify to see the content. |
comp |
string | No | AND | Option to set the comparison between multiple requirements. Accepts either "AND" or "OR". |
user_id |
int or string | No | - | Option to set the requirement for viewing the content to a particular user. Should not be used unless you must check a different users requirement than the one viewing the shortcode. |
CSS Styling
// Wrapping element around content div.mycred-hide-this-content { }
Examples
Example 1: Hide content if the current user is: logged in and have 100 points or more.
[mycred_hide_if balance=100]Hidden content.[/mycred_hide_if]
Example 2: Hide content if the current user is: logged in and have 0.010 points or more.
[mycred_hide_if balance="0.010"]Hidden content.[/mycred_hide_if]
Example 3: Hide content if the current user is: logged in and have the “Commander“ rank.
[mycred_hide_if rank="Commander"]Hidden content.[/mycred_hide_if]
Example 4: Hide content if the current user is: logged in, have 1000 points or more and have the “Commander“ rank.
[mycred_hide_if balance=1000 rank="Commander"]Hidden content.[/mycred_hide_if]
Example 5: Hide content if the current user is: logged in and have gained points for approved comments at least 10 times.
[mycred_hide_if ref="approved_comment" count=10]Hidden content.[/mycred_hide_if]
Example 6: Hide content if the current user is: logged in and must have either a) gained points for approved comments at least 10 times OR have the rank “Master“.
[mycred_hide_if ref="approved_comment" count=10 rank="Master" comp="OR"]Hidden content.[/mycred_hide_if]
Example 7: Hide content if the current user is: logged in have at least 100 tokens (a custom point type)
[mycred_hide_if balance=100 ctype="customtypekey"]Hidden content.[/mycred_hide_if]