Hi,
WordPress default model of a work with roles: create roles on setup and forget about them.
A lot of plugins including very popular like WooCommerce and others create its roles on plugin activation.
Created roles are stored at WordPress database and this fact makes possible to change them with help or User Role Editor or similar plugins.
Project Panorama Lite plugin uses ‘admin_init’ event to re-create its roles. Thus it executes its roles creation code for every page opening at wp-admin.
Look at the file project-panorama-lite/lib/psp-helpers.php file, line #632:
add_action( 'admin_init', 'psp_add_project_roles' );
and line #697:
add_action('admin_init','psp_add_role_caps',999);
This is a reason why changes you try to make to PPL plugin roles are reverted back.
Ultimate Member plugin works with its roles similar way as a PPL plugin. It just use a different event in order to initialize its own roles:
Look at the file ultimate-member/includes/core/class-role-capabilities.php, line #22:
add_action( 'wp_roles_init', array( &$this, 'um_roles_init' ), 99999 );
‘wp_roles_init’ event fires for every page opening. Thus it does not have sense to modify such role stored at the WP database. UM plugin will modify it back on the page load.
The only workaround is to write code which will be executed after such plugin roles refresh code and modify them as needed to you.
Thread Starter
davask
(@davask42)
Hi Vladimir,
thank you so much for the explanation.
I actually created roles from your plugin instead of using Ultimate member for instance, using my own naming convention and it works as expected so no need to overwrite code 🙂
Thanks,
you made my day 😉
david