Plugin Planet

Premium WordPress Plugins

USP Pro includes a plethroa of shortcodes to use for displaying forms, submitted content, and more. In this post, we will look at some examples of using USP Pro shortcodes and using nested shortcodes to display forms only if the user is logged in to the site.

Display form based on user capability

Here we are using nested shortcodes to display the form only to users who have the ability to “read”, as specified by the cap attribute:

[usp_access cap="read" deny="usp_access"]
[usp_form id="submit"]
[/usp_access]

Here, the deny attribute is the message that will be displayed to visitors who do not meet the requirements.

To display the form only to, say, admins, we could replace “read” with “manage_sites” or equivalent. Check out the WP Codex for a complete guide to user roles.

Display form only if user is logged in

Here we are displaying the form only if the current user is logged in:

[usp_member deny="usp_member"]
[usp_form id="submit"]
[/usp_member]

As before, the deny attribute contains the message that will be displayed to users who do not meet the requirements.

Display form only if the user is not logged in

Lastly, here is a nested shortcode combo to display the form only for visitors (users who are not logged in to the site):

[usp_visitor deny="usp_visitor"]
[usp_form id="submit"]
[/usp_visitor]

As before, the deny attribute contains the message that will be displayed to users who do not meet the requirements.

For more details about these and other USP Pro shortcodes, visit USP Pro Shortcodes.

Related: