Change plugin option from function.php
-
Hi there,
For my website I’m using the plugin Woocommerce Variations to Table Grid, but I would like to restrict this one only for some roles ‘Administrator’ and ‘wholesaler’. (my website is for wholesalers and ‘normal’ customer)
Anyway I was thinking to just desactivate the plugin by checking the user role so I tried the following solution : https://wordpress.stackexchange.com/questions/159085/deactivate-plugin-for-a-specific-user-group
Doesn’t work.I’ve got a variable in my plugin called $vartable_disabled which is a boolean which “Disable globally” the plugin.
So I am thinking to do something in my functions.php like:
add_action('admin_init', 'my_option_change_plugins'); function my_option_change_plugins() { global $current_user; if (!in_array('administrator' || 'wholesaler', $current_user->roles)) { deactivate_plugins( // activate for variation-table $vartable_disabled == 0 $vartable_position == 'under' ); } else { // desactivate for those than can't use it activate_plugins( $vartable_disabled == 1 $vartable_position == 'side' ); }
But for sure I’m doing something wrong, I tried plenty of different thing the whole day, impossible to figure it out.
Anyone can help?
Cheers ??
- The topic ‘Change plugin option from function.php’ is closed to new replies.