문제

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.

도움이 되었습니까?

해결책

It 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top