Skip Navigation

[Resolved] How to assign an existing custom post to a suscriber using the author dropdown

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 2 replies, has 2 voices.

Last updated by ralphN-2 1 year, 11 months ago.

Author
Posts
#2364973

Tell us what you are trying to do?

Hello, I created a custom post type using Toolset and now want to reassign the post ownership from myself (admin) to some users who are subscribers. I tried everything mentioned in the following thread (see link below), but it won't work:
https://toolset.com/forums/topic/cannot-assign-a-subscriber-as-the-author-of-a-custom-post/

After adding the code, the dropdown menu continues to contain only administrators. There is one subscriber user existing but it won't show in the dropdown.

Is there any documentation that you are following?
https://developer.wordpress.org/reference/hooks/wp_dropdown_users_args/

I have tried adding the following code snippets - non did work for me:

1)
add_filter('wp_dropdown_users_args', 'assign_subscriber_author_func', 10, 2);
function assign_subscriber_author_func($query_args, $r){
$query_arg['who'] = 'subscriber';
return $query_arg;
}

2)
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;
}

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

What can I do to make this work? Thanks! Ralph

#2364997

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Are you also using Toolset Access to give Subscribers rights to publish posts of that type?

If I recall correctly, because Subscribers are a role with no publication rights, you need to modify the role so that they do have publication rights, but because it is a built-in role, that may not be enough, meaning you additionally need custom code to make it possible.

But as a first step, first confirm that you have modified the Subscriber role to grant publish permissions, using Access.

#2364999

Dear Nigel, this did the trick!! My issue is resolved now. Thank you so much!

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