Is there a plugin, or a way to automatically create a set of default posts for a new user when they register? I suspect that the answer might be to hook into the existing wordpress events - can anybody suggest a way to get started?

1 Answer 1


A combination of user_register and wp_insert_post should work fine:

add_action('user_register', 'create_postset');

function create_postset($user_id) {
    // userinfo
    $user_info = get_userdata($user_id);
    // Create post objects
    $post_1 = array(
        'post_title' => '1st post created for ' . $user_info->user_login,
        'post_content' => 'Lorem Ipsum',
        'post_status' => 'publish',
        'post_author' => $user_id
    $post_2 = array(
        'post_title' => '2nd post created for ' . $user_info->user_login,
        'post_content' => 'Lorem Ipsum',
        'post_status' => 'publish',
        'post_author' => $user_id

    // Insert posts into the database
  • 1
    The OP already knows that hooks are needed. This barely expands upon that. Can you provide some plausible sample code to demonstrate how you would do this?
    – s_ha_dum
    Commented Jun 30, 2013 at 16:42
  • It seemed like he just had no idea which keywords he should try to find a hook that fits his needs. So in that specific case I guess he would have been sucessful without a codesample. But nevertheless it's always quite cool to have a functional copy&paste snippet, so I just edited my answer.
    – rfrq
    Commented Jun 30, 2013 at 18:12
  • that may be true but the site policy is to provide answers that help the general population and not just the OP. That means more complete answers than might strictly be necessary along with code if possible. Your original answer, by the way, was flagged by the automated system as being "low quality". Now it would not be.
    – s_ha_dum
    Commented Jun 30, 2013 at 18:18
  • That's exactly what I was looking for, many thanks. I think that this is the first time I've not been able to find a plugin that does what I want!
    – mojones
    Commented Jun 30, 2013 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.