WordPress.org

Ready to get started?Download WordPress

Forums

[PHP] Change post author? (3 posts)

  1. jmeit
    Member
    Posted 2 years ago #

    I would like to be able to change the author of a post.
    I have the post-id, the user-id that I want to transfer it to, and I have the user-id that the post currently belongs to.

    I need to do this with php, because it must happen automatically. This reassignment of authors must occur upon a certain event that I am currently hooking into. Meaning, I don't want to be doing this in the Dashboard.

    I can't find anything on google.

  2. Rescuework Support
    Member
    Posted 2 years ago #

    WordPress has wp_update_post.

    http://codex.wordpress.org/Function_Reference/wp_update_post

    This function updates posts (and pages) in the database. To work as expected, it is necessary to pass the ID of the post to be updated.

  3. jmeit
    Member
    Posted 2 years ago #

    Thank you SO much! This was exactly what I needed.
    I don't know why this didn't turn after days of searching google.

Topic Closed

This topic has been closed to new replies.

About this Topic