User management is an essential part of most advanced applications with WordPress. In such applications, different users have access to different content based on their capabilities. So, it's important to have features for allowing/restricting certain parts of the posts/pages based on the type of user. Shortcodes are the ideal way of restricting parts of the post/page content and allowing other parts of the content to all users.
In this recipe, we are going to create a shortcode that allows us to limit the content within the shortcode to members of the sites, as well as users with a specific user role.