protect certain roles | WordPress.org

[ad_1]

I had tweaked a previous version of this plugin to not only ignore the ‘administrator’ role when deciding how to apply new roles to imported users, but also a whole slew of additional role names, by using an ‘array_intersect()’. However, this seems to no longer be working with the latest version of the plugin and php 8.0. Is there another different check performed to line ~569 in classes/import.php, or am I just a bad programmer?

These were my two replacement lines to the original ‘if( !( in_array(“administrator”,’… line, making sure the user is not any of the listed protected roles:

$protected_roles = array(‘administrator’,’board_member’,’give_worker’,’give_manager’,’give_accountant’,’give_donor’,’give_subscriber’);

if( !( count(array_intersect($protected_roles, $acui_helper->get_roles_by_user_id( $user_id ))) == 0 || is_multisite() && is_super_admin( $user_id ) )){

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer