Limit Beaver Builder modules by user level

Limit Beaver Builder modules by user level

Chris in the Beaver Builder FB group asked if it was possible to limited the beaver builder modules by the user level.

The answer is yes! using a lil’ PHP code we can restrict the available plugins by all sorts of capabilities.



<?php


function simple_modules($setting){

  $basicModules = array( // these are all the standard BB pro modules that will be displayed. Remove and season to taste.
    "audio",
    "button",
    "html",
    "heading",
    "photo",
    "separator",
    "rich-text",
    "video",
    "content-slider",
    "gallery",
    "icon",
    "icon-group",
    "map",
    "slideshow",
    "testimonials",
    "cta",
    "callout",
    "contact-form",
    "menu",
    "social-buttons",
    "subscribe-form",
    "accordion",
    "pricing-table",
    "sidebar",
    "tabs",
    "countdown",
    "numbers",
    "post-grid",
    "post-carousel",
    "post-slider"
  );
  

  
  // if you only want to restrict by post type, use this if statement.
  if ( is_singular( 'posts' ) ) 
  {
    return $basicModules;
  }

  // if you want to restrict modules by user role, use this if statement.
  if ( current_user_can( 'subscriber' ) ) // only if subscriber
  {
    return $basicModules;
  }

  //return default settings or you'll break bb for everyone else.
  return $setting;
}

add_action('fl_builder_enabled_modules','simple_modules');

COMMENTS:

Leave a Comment





Level up your Beaver Builder skills

Over 2,000 Beaver Builders can't be wrong!

We've got a million ideas that we've implemented on over 100+ BB enabled websites.

Pop in your email below, and we'll let you know when a new post or plugin is available 🙂

Newsletter

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Spam sucks.