Shortcode-based restrictions

First, we have to define a shortcode that handles content restrictions. In the forum application, we have several user roles. The shortcode created in this section should be able to provide restrictions for each of these user roles. We can start by creating a new class for content restrictions called WPWAF_Content_Restrictions inside the classes folder of our forum plugin. Then, we need to include the file inside the includes function of the WPWAF_Forum class and initialize the object inside the instance function of the same class.

Let's start by defining the shortcode inside the constructor, as shown in the following code:

    class WPWAF_Content_Restrictions{       public function __construct(){  add_shortcode( 'wpwaf_private_content', ...

Get Wordpress Web Application Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.