In this members-only tutorial, we shall

  • add a custom function to check if the currently logged-in user has a specific WordPress role
  • add a custom shortcode to not output elements based on user role using the above function
  • use this shortcode in a Shortcode Wrapper element of Oxygen

so that sections (or any other element or content) wrapped in [dont_output_for role="editor"][/dont_output_for], for example, will be output and shown to all users other than editors.

Step 1

Install and activate Code Snippets plugin.

Step 2

Go to Snippets > Add New.

Title: Function to check if the user has a specific role

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($37/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: