Using custom user data in containing shortcode
Now that we have additional data stored in user profiles and have facilitated the viewing of this information in the administration pages, the only missing component to achieve our goal of restricting some site content to paid users is to introduce a new enclosing shortcode that will check a user's level before displaying content. The recipe will show how to create this new shortcode.
Getting ready
You should have already followed the Display new user data in user list page recipe to have a starting point for this recipe and the resulting plugin should still be active in your development site. Alternatively, you can get the resulting code (Chapter 7/ch2-private-item-text/ch2-private-item-text-v5.php
) from the Chapter 7, Customizing User Data section of the downloaded code bundle, renaming it as ch2-private-item-text.php
.
How to do it...
- Navigate to the
ch2-private-item-text
folder of the WordPress plugin directory of your development installation...