Skip to content

Instantly share code, notes, and snippets.

@wanye71
Created November 17, 2012 22:21
Show Gist options
  • Save wanye71/4100723 to your computer and use it in GitHub Desktop.
Save wanye71/4100723 to your computer and use it in GitHub Desktop.
Auto Assigning Categories To Posts
<?php
function sce_create_page($user_id){
$the_user = get_userdata($user_id);;
$new_user_name = $the_user->user_login;
$my_post = array();
$cat_name = wp_create_category('premium');
$my_post['post_title'] = $new_user_name . $cat_name;
$my_post['post_type'] = 'post';
$my_post['post_content'] = '';
$my_post['post_status'] = 'publish';
wp_insert_post( $my_post);
}
add_action('user_register', 'sce_create_page');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment