#32585 closed defect (bug) (fixed)
Programmatically using wp_insert_post with post_author=0 does not work when user is logged in
Reported by: | ericdaams | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-patch needs-testing needs-unit-tests |
Focuses: | Cc: |
Description
Passing a post_author
of 0 to wp_insert_post
does not work if the user is logged in.
Reproducible with:
add_action( 'init', function() { $args = array( 'post_title' => 'test', 'post_author' => 0 ); $post_id = wp_insert_post( $args ); echo get_post_field( 'post_author', $post_id ); // post_author is 1 });
post_author
returns 1, despite post_author
being set explicitly to 0.
Attachments (2)
Change History (7)
#2
@
9 years ago
- Keywords needs-testing needs-unit-tests added
- Version 4.2.2 deleted
Thanks for the patch, ericdaams!
This will need some unit tests.
#3
@
9 years ago
- Summary changed from Programatically using wp_insert_post with post_author=0 does not work when user is logged in to Programmatically using wp_insert_post with post_author=0 does not work when user is logged in
Note: See
TracTickets for help on using
tickets.
Using isset instead of empty ensures that post_author of 0 is correctly handled.