12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Nov 5, 2018

How to unpublish Oxygen Sections for specific user roles

Sridhar Katakam

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


This is a premium members-only content.

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

Already a member? Log in below or here.