How it works...
First, we added a new shortcode called wpccp_chapter7_restrict_access for restricting content within the shortcode. The shortcode callback function contains attribute values as the first parameter and content as the second parameter. Inside the callback function, we use the shortcode_atts function to define the available attributes for this shortcode.
This is a built-in function that's used to combine the attribute values that are passed to the shortcode with default attributes and generate an array of attributes and values. In this scenario, we defined two attributes called type and role. The type parameter will be used to define the type of restriction and set to all by default. So, the content will be allowed for everyone ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access