Skip Navigation

[Resolved] Custom Role cannot be assigned as author for posts

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

Problem:
How to display author dropdown with users having custom role assigned

Solution:
You can use wordpress hook wp_dropdown_users_args to override the arguments of your author dropdown.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/custom-role-cannot-be-assigned-as-author-for-posts/#post-901564

Relevant Documentation:
https://developer.wordpress.org/reference/functions/post_author_meta_box/

This support ticket is created 6 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by ChuckGregory 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#901386

Tell us what you are trying to do? I want each user of custom role 'member' to own their own custom post of type 'member'

Is there any documentation that you are following? i read all the access documentation

Is there a similar example that we can see?

What is the link to your site? hidden link
This page should be owned by Roots Family Farm Shop but they aren't listed in author dropdown when editing

Note: I'm working on this site as a toolset contractor.

#901546

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - have you activated the "Author" checkbox option by editing your custom post type under section "Sections to display when editing member"? If no: could you please activate that checkbox and save your post type and try to resolve your issue.

#901560

Thanks, Minesh, but you misunderstood the problem. The dropdown does show up, but only the three admin accounts are listed as options to be 'author' of the member posts.
I'm sure it's related to the capabilities I've assigned to the custom role I defined, but I don't know what I need to add to make users with that role available as 'author' for posts.
Thanks.

#901564

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please try to add following code to your current theme's functions.php file and try to resolve your issue.

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

This will dispaly 'any' (all) user with author dropdown. However - you can change the 'any' value as per your requirement. For more info on that please visit following link:

More info:
https://developer.wordpress.org/reference/functions/post_author_meta_box/

#901568

Perfect! I think I had to do this on another site last year, but I did not remember the trick. Much appreciated.