Make WordPress Core

Opened 12 months ago

Last modified 8 weeks ago

#24088 new enhancement

Update get_users_drafts() to support custom post types

Reported by: navjotjsingh Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5.1
Component: Users Keywords: has-patch
Focuses: Cc:


Currently get_users_drafts() access drafts of 'post' type only. Would be useful if it could support custom post types as well.

Attachments (2)

24088.patch (1.3 KB) - added by mordauk 8 weeks ago.
Add support for passing post types to get_users_drafts()
24088.2.patch (1.3 KB) - added by mordauk 8 weeks ago.

Download all attachments as: .zip

Change History (8)

comment:1 mordauk8 weeks ago

+1 for sure, though I think the function should also be updated to use WP_Query in order to leverage existing APIs and take caching into account.

comment:2 mordauk8 weeks ago

It seems very strange to me that this function only returns the ID and post_title fields instead of standard post objects.

The function isn't actually used anywhere in core, so perhaps we should leave it exactly as is but add a $post_type parameter to the function.

mordauk8 weeks ago

Add support for passing post types to get_users_drafts()

comment:3 mordauk8 weeks ago

24088.patch adds support for custom post types and adds $user_id to the get_users_draft filter.

comment:4 DrewAPicture8 weeks ago

  • Keywords has-patch added

Just a couple nitpicks on 24088.patch, but the slash in @param string/array should be a pipe character, |, and $post_type should also be marked 'Optional.'

Unrelated: Does it seem odd that the query string itself is filterable rather than the results here?

comment:5 mordauk8 weeks ago

I thought it was odd that the query arguments weren't filterable. I chalked it up to the function not being used anywhere in core.

I'd definitely like to make the arguments filterable though I'd worry about backwards compatibility with any plugins that are using the function.

mordauk8 weeks ago

comment:6 mordauk8 weeks ago

Refreshed patch with correct PHPDoc.

Note: See TracTickets for help on using tickets.