Authors selected on install broader than on add/delete
-
Hi there,
Noticed what I think might be some unexpected undesired behavior here.
When installing, the plugin runs this…
$author_users_opt = array( 'who' => 'authors', 'name' => 'admin10x_install', 'class'=> 'authors', 'show' => 'display_name_with_login' ); $authors = get_users( $author_users_opt ); foreach($authors as $author) { error_log(json_encode($author->data)); $this->add_author($author->data->ID); }
And from the docs…
https://codex.www.ads-software.com/Function_Reference/get_userswho - If set to 'authors', only authors (user level greater than 0) will be returned.
Then, on the
set_user_role
action, it runs as follows…add_action('set_user_role', function($user_id, $role) { $a10x = new Admin10X(); $author_roles = array('administrator', 'author', 'editor'); if ( in_array($role, $author_roles)) { $a10x->add_author($user_id); } else { $a10x->del_author($user_id); } }, 10, 3);
… which is a narrower slice.
So, for example, on install, the table will include contributors, however, when you add a new contributor they’re not in the table.
Proposed solution would be (a) a plugin setting for which roles are considered for this table and (b) update the plugin to use the value(s) from this setting for both the
role__in
on theget_users()
and the$author_roles
in theset_user_role
action.Thank you for this most excellent plugin that so elegantly solves the too many authors slow query in admin issue.
- The topic ‘Authors selected on install broader than on add/delete’ is closed to new replies.