admin管理员组文章数量:1130349
Given a user id, $user_id, and post id, $post_id, how can I programatically update a wordpress post author?
Note: these posts are already created and the author cannot be set upon creation. Another process is creating the post and defaulting to the admin as the author. I don't have access to creating the post but have access after it is created.
Given a user id, $user_id, and post id, $post_id, how can I programatically update a wordpress post author?
Note: these posts are already created and the author cannot be set upon creation. Another process is creating the post and defaulting to the admin as the author. I don't have access to creating the post but have access after it is created.
Share Improve this question asked May 4, 2015 at 16:15 italiansodaitaliansoda 4461 gold badge6 silver badges14 bronze badges2 Answers
Reset to default 28It shouldn't be any problem. Try this:
$arg = array(
'ID' => $post_id,
'post_author' => $user_id,
);
wp_update_post( $arg );
you can also just add another admin account. delete the one that's authoring the posts and WP will ask where to assign posts. Choose preferred author, done.
Given a user id, $user_id, and post id, $post_id, how can I programatically update a wordpress post author?
Note: these posts are already created and the author cannot be set upon creation. Another process is creating the post and defaulting to the admin as the author. I don't have access to creating the post but have access after it is created.
Given a user id, $user_id, and post id, $post_id, how can I programatically update a wordpress post author?
Note: these posts are already created and the author cannot be set upon creation. Another process is creating the post and defaulting to the admin as the author. I don't have access to creating the post but have access after it is created.
Share Improve this question asked May 4, 2015 at 16:15 italiansodaitaliansoda 4461 gold badge6 silver badges14 bronze badges2 Answers
Reset to default 28It shouldn't be any problem. Try this:
$arg = array(
'ID' => $post_id,
'post_author' => $user_id,
);
wp_update_post( $arg );
you can also just add another admin account. delete the one that's authoring the posts and WP will ask where to assign posts. Choose preferred author, done.
本文标签: Programatically change post author
版权声明:本文标题:Programatically change post author 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749122168a2319186.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论