您可以使用wp_update_post()
$my_post = array(
\'ID\' => $post_id,
\'post_author\' => $user_id,
);
wp_update_post( $my_post );
或者使用GravityForms uploader通过函数更改图像的作者
add_action("gform_user_registered", "image_author", 10, 4);
function image_author($user_id, $config, $entry, $user_pass)
{
$post_id = $entry["post_id"];
$args = array(
\'post_parent\' => $post_id,
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\'
);
$attachments = get_posts($args);
if($attachments) :
foreach ($attachments as $attachment) : setup_postdata($attachment);
$the_post = array();
$the_post[\'ID\'] = $attachment->ID;
$the_post[\'post_author\'] = $user_id;
wp_update_post( $the_post );
endforeach;
endif;
}