I am managing a few sites now using the beaver builder plugin and when I mass update the plugin using MainWP/ManageWP etc I need to also be able to mass update the new modules on all sites. I can write a plugin and mass update to all my sites, so I was just wondering if there was a function to activate/deactivate modules one-by-one?
However, I’m not entirely sure this will work for you as it only allows you to disable modules, not enable them. To do that, you might consider working with the “_fl_builder_enabled_modules” option that is stored in the database. That option contains an array of all of the module slugs that are active. If it contains the word “all” then all modules will be active.
You can modify that array using get_option and update_option to add and remove modules that are active.
Great! got it working. I needed it so I can activate / deactive modules for all my clients using a self-hosted plugin. Here is the code I ended up using.
add_action( 'init', 'myweb_update_options' );
function myweb_update_options(){
// get currently activate BB modules from the db
$bbactivatedmodules = get_option('_fl_builder_enabled_modules');
// define the modules we want to be active
$myweb_bbactivatedmodules = array(
'heading',
'photo',
'separator',
'rich-text',
'video',
'accordion',
'button',
'cta',
'callout',
'content-slider',
'gallery',
'html',
'icon',
'icon-group',
'map',
'post-grid',
'post-carousel',
'post-slider',
'pricing-table',
'slideshow',
'tabs',
'testimonials',
'woocommerce',
);
// if the modules we want activates are already set, do nothing
if($bbactivatedmodules == $myweb_bbactivatedmodules){return;}
// else activate the modules we want
else{
unset($bbactivatedmodules);
//print_r($myweb_bbactivatedmodules);
update_option( '_fl_builder_enabled_modules', $myweb_bbactivatedmodules );
}
}