Using custom user data in an enclosing shortcode
Now that we have additional data stored in user profiles and have made it easy to view this information on the administration pages, we can finally complete our content subscription system. The only missing component to achieve our goal of restricting site content to paid users is to introduce a new enclosing shortcode that checks a user's membership level before displaying content.
Getting ready
You should have already followed the Displaying new user data on the user list page recipe to have a starting point for this recipe. The resulting plugin should still be active on your development site. Alternatively, you can get the resulting code directory (ch8/ch2-private-item-text/*
) from the book's GitHub page and rename ch2-private-item-text-v5.php
to ch2-private-item-text.php
. All other .php
files can be deleted to avoid confusion when activating the plugin.
How to do it...
Follow these steps to create a new enclosing...