mycred_show_if

Description

This shortcode allows you to show parts of your content for those who fulfil the requirements you set. This shortcode is the opposite of the mycred_hide_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 then the one viewing the shortcode.

CSS Styling

// Wrapping element around content
div.mycred-show-this-content { }

Examples

Example 1: To view the content, the current user must be: logged in and have 100 points or more.

[mycred_show_if balance=100]Content hidden by this shortcode[/mycred_show_if]

Example 2: To view the content, the current user must be: logged in and have 0.010 points or more.

[mycred_show_if balance="0.010"]Content hidden by this shortcode[/mycred_show_if]

Example 3: To view the content, the current user must be: logged in and have the “Commander“ rank.

[mycred_show_if rank="Commander"]Content hidden by this shortcode[/mycred_show_if]

Example 4: To view the content, the current user must be: logged in, have 1000 points or more and have the “Commander“ rank.

[mycred_show_if balance=1000 rank="Commander"]Content hidden by this shortcode[/mycred_show_if]

Example 5: To view the content, the current user must be: logged in and have gained points for approved comments at least 10 times.

[mycred_show_if ref="approved_comment" count=10]Content hidden by this shortcode[/mycred_show_if]

Example 6: To view the content, the current user must be: logged in and must have either a) gained points for approved comments at least 10 times OR have the rank “Master“.

[mycred_show_if ref="approved_comment" count=10 rank="Master" comp="OR"]Hidden content[/mycred_show_if]

Example 7: To view the content, the current user must be: logged in have at least 100 tokens (a custom point type)

[mycred_show_if balance=100 ctype="customtypekey"]Content hidden by this shortcode[/mycred_show_if]