Skip Navigation

[Resolved] Author dropdown is not available when Toolset Access plugin is activated

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to add a custom user role users to the author dropdowns on the backend.

Solution:
This will require custom code such as:

function wpdocs_add_members_to_dropdown( $query_args, $r ) {
     
    $query_args['role'] = array('member', 'administrator');
     
    // Unset the 'who' as this defaults to the 'author' role
    unset( $query_args['who'] );
     
    return $query_args;
}
add_filter( 'wp_dropdown_users_args', 'wpdocs_add_members_to_dropdown', 10, 2 );
This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 9 replies, has 2 voices.

Last updated by Jamal 2 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2172205
Author_dropbdown.jpg

I have an issue when the Author dropdown (on Admin -> post edit page) is not available when the Toolset Access plugin is activated. Screenshot is attached
- I have multiple admins and other user roles
- I have some access limits set up in Toolset Access to other user roles but not to admins. So I should be able to see at least admin in the Author dropdown.
- I use the Astra theme. When I change the theme to the Twenty Twenty one, nothing changes.
- other plugins deactivation doesn't make any difference.

Not sure if it's a bug or I did something wrong. I would be happy to hear your advice.

#2172797

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting Toolset support.

Does this happen to regular post types(Posts and Pages) or to a custom post type defined by Toolset(or another plugin)?
If it is happening to custom post types, edit the post type in Toolset->Post Types, and add the author option to it. Check this screenshot hidden link
This should be enough to get admins, editor, and authors(default WordPress roles) to appear in the authors' dropdown.

If you need to display custom roles(from Toolset Access or somewhere else), you'll need to add custom code to change the roles of the users that can be made authors. Check an example here https://toolset.com/forums/topic/cant-add-new-user-with-new-custom-role-as-author/
And here hidden link

I hope this helps. Let me know if you have any questions.

#2174269

Hi Jamal. Thank you for your reply.
The issue happens with all custom post types (all defined by Toolset and all of them have "author" field activated) and pages. For some reason, regular posts' authors can be changed.

Thank you for letting me know how to display custom roles. I would need that a well so I will check pages you've shared.

#2174343

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Awesome. Let me know if you need further assistance. At this point, I'll set this ticket as waiting for your reply which should keep it open for a couple of weeks. You will receive reminders notifications before it gets closed.

#2175297

Hi Jamal. I've tried the solution with a code snippet from this link https://toolset.com/forums/topic/cant-add-new-user-with-new-custom-role-as-author/ and it worked in terms of adding a custom role to the authors dropdown. However, I keep facing the issue but with some updates after adding the snippet:
now author dropdowns are available BUT dropdowns give options of all custom role users and only one admin ( I have more admin users).

I checked Toolset Access settings for admins just in case but everything is marked, so basically, there are no limitations for admins..

#2175315

additionally (in case it matters), when I delete any user I can attribute all content only to users with a custom role.

#2178405

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

What if you update the code to include the administrators too? Something like:

function wpdocs_add_members_to_dropdown( $query_args, $r ) {
    
    $query_args['role'] = array('member', 'administrator');
    
    // Unset the 'who' as this defaults to the 'author' role
    unset( $query_args['who'] );
    
    return $query_args;
}
add_filter( 'wp_dropdown_users_args', 'wpdocs_add_members_to_dropdown', 10, 2 );

If it does not help, we should first exclude any possible compatibility issues. Please check if these issues appear when:
- Only Toolset plugins are activated. It will tell us if there is an interaction issue with another plugin.
- The theme is set to a WordPress default like Twenty-Twenty. It will tell us if there is an interaction issue with your theme.
If the problem disappears, start activating one at a time to track where the incompatibility is produced.

#2178671

Hi Jamal. Thank you. I've tried the updated code you've sent me and it made the dropdown disabled like it was before. So I returned your code snippet previous version.
I tried to disable all plugins except Toolset as well as I tried Twenty Twenty one theme - same issue, no difference. But as soon as I deactivate the Toolset Access plugin everything comes back to normal.

#2178685

Jamal, I tried to use 'role__in' instead of "role" in your snippet which includes "administrator" and it worked for me.
$query_args['role__in'] = array('member', 'administrator');
Now I can chose administrators in author dropdowns as well as attribute content to them when delete user.

#2178689

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Awesome. I am glad you get it fixed. And thank you for sharing the fix that you implemented.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.