Title: Programatically adding a new author
Last modified: August 19, 2016

---

# Programatically adding a new author

 *  [Kratzy](https://wordpress.org/support/users/kratzy/)
 * (@kratzy)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/programatically-adding-a-new-author/)
 * I’m working on a script that automatically adds posts using PHP. I have managed
   to get my script to add posts using `wp_insert_post()`, but I also want the posts
   to use the appropriate author, which may not even exist.
 * At the moment I have it set up to use the user ID of 1 (myself), but I would 
   like to also specify a user that perhaps doesn’t exist in my WordPress install.
   For example say I have 3 author: Bob, Harry and Bill. The post I want to add 
   comes from another author: Jane. Seen as Jane hasn’t been seen before, I need
   to add her to my WordPress install before I use her user ID in the `wp_insert_post()`
   function.
 * Is there a ready made function to do this? I tried searching the Codex but I’m
   unsure of what to specifically search for.
 * Thanks.

Viewing 1 replies (of 1 total)

 *  [GRAQ](https://wordpress.org/support/users/graq/)
 * (@graq)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/programatically-adding-a-new-author/#post-1957962)
 * wp_create_user lets you add users
 * [http://codex.wordpress.org/Function_Reference/wp_create_user](http://codex.wordpress.org/Function_Reference/wp_create_user)
 * Make sure to look up WP_Role / set_role for the new user’s role.
 * You can check if the user exists with username_exists()

Viewing 1 replies (of 1 total)

The topic ‘Programatically adding a new author’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [GRAQ](https://wordpress.org/support/users/graq/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/programatically-adding-a-new-author/#post-1957962)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
