Skip Navigation

[Résolu] make subscriber user author.

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.

This topic contains 3 réponses, has 2 voix.

Last updated by Jamal Il y a 2 mois et 1 semaine.

Assigned support staff: Jamal.

Auteur
Publications
#2056823

I have given 'Publish' and 'Edit Own' permission to the default WordPress user role 'Subscriber'. I have done this for a custom post type.

After doing this, I am not able to see any users with the subscriber role in the post author dropdown on the custom posts.

Please help.

#2056861

Jamal
Supporter

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

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

I escalated this case to our 2nd Tier for further analysis, and I am getting back to you with a workaround solution.

You can add the following custom code to a Toolset snippet and make all the users available in the author dropdown:

add_filter( 'wp_dropdown_users_args', 'add_subscribers_to_dropdown', 10, 2 );
function add_subscribers_to_dropdown( $query_args, $r ) {

    $query_args['who'] = '';
    return $query_args;

}

The wp_dropdown_users_args hook offers more control, the following code will enable only the subscribers and administrators to be selected in the users dropdown:

function wpdocs_add_subscribers_to_dropdown( $query_args ) {
 
    // Use this array to specify multiple roles to show in dropdown
    $query_args['role__in'] = array( 'subscriber', 'administrator' );
 
    // Use this array to specify multiple roles to hide in dropdown
    $query_args['role__not_in'] = array( 'editor' );
 
    // 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_subscribers_to_dropdown' );

Please note that this works only for the drop-down in the custom post type list. Check this screenshot hidden link

I'll get back to you as soon as I have something to share.

#2059355

Thank you for sharing this. Will this option be incorporated in the plugin in the future? removing the need to add custom code?

#2059465

Jamal
Supporter

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

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

The request has been escalated to the developers, however, we can't tell when this will be implemented. It may take some months before it lands into Toolset Access.

As of now, the workaround will require custom code. I shared the custom code that should work for the posts list(quick edit), and in the classic editor. You will need a different code to support the Gutenberg editor.
Please check this article for a custom code reference hidden link