#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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.4 |
| Component: | Posts, Post Types | Version: | |
| Severity: | normal | Keywords: | has-patch needs-testing needs-unit-tests |
| Cc: | Focuses: |
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
@
11 years ago
- Keywords needs-testing needs-unit-tests added
- Version 4.2.2
Thanks for the patch, ericdaams!
This will need some unit tests.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Using isset instead of empty ensures that post_author of 0 is correctly handled.