• Why would you include the prefix of the db as part of the option name in the db? If someone ever needs to change the prefix in the future your plugin will lock out all admins to the website because the roles no longer work.

    The option name has nothing to do with the prefix of the db tables so you should clean up your plugin and change the option names to user_roles and backup_user_roles.. otherwise you’re going to cause a lot of headaches for people when they’re migrating or changing prefixes.

    Bart

Viewing 1 replies (of 1 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi Bart,

    I’m not a real author of this idea.

    WordPress creates user roles at the database during setup using code from wp-admin/includes/schema.php, function populate_roles(), which uses ‘add_role()’ from wp-includes/capabilities.php, which uses WP_Roles->add_role(), in which you can see:

    
    if ( $this->use_db )
    	update_option( $this->role_key, $this->roles );
    

    Look at the wp-includes/class-wp-roles.php, line #113, how $this->role_key property is initialized:

    
    protected function _init() {
    	global $wp_user_roles, $wpdb;
    
    	$this->role_key = $wpdb->get_blog_prefix() . 'user_roles';
    

    So, User Role Editor plugin just uses what we already have from WordPress core and follows the same rule when creates user roles backup record.

Viewing 1 replies (of 1 total)
  • The topic ‘DB prefix is included in option name breaking after prefix change’ is closed to new replies.