• Resolved walilkoa

    (@walilkoa)


    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 ) )){

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Javier Carazo

    (@carazo)

    You should never tweak this plugin (or any other).

    You could have asked to include a filter in order you can hook it without changing our code.

    I am going to prepare it and tell you to update.

    Plugin Author Javier Carazo

    (@carazo)

    You have it ready in version 1.21.7

    Filter is this one:

    if( empty( array_intersect( apply_filters( ‘acui_protected_roles’, array( ‘administrator’ ) ), $acui_helper->get_roles_by_user_id( $user_id ) ) ) || is_multisite() && is_super_admin( $user_id ) ){

    And please remind to avoid tweak any plugin, we can create hooks to make your needs possible but you never should change it.

    Thread Starter walilkoa

    (@walilkoa)

    Awesome, thank you for the quick turnaround! I’ll add this as a filter in my theme file instead, and put in the latest vanilla plugin. Down the road, it might be very cool to have this as a selectable checkbox array in the admin panel, but this alone is perfect!

    Plugin Author Javier Carazo

    (@carazo)

    This is a non usual requirement, so surely it has no sense to include more fields in the form to show it to everyone. Surely you are the one of hundreds of users that has needed it.

    Thanks for using this plugin and if you like our support please rate us.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘protect certain roles’ is closed to new replies.