Created
June 30, 2013 05:37
-
-
Save teolopez/5893997 to your computer and use it in GitHub Desktop.
When a new user registers a new post is auto created and assigned to the new user as a draft.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------------------------------- | |
// Add Post On New User Registration and Assign to User Registration | |
// ----------------------------------------------------------------- | |
add_action( 'user_register', 'gamma_new_user_post' ); | |
/** | |
* Add a new post when user registers. | |
*/ | |
function gamma_new_user_post( $user_id ) { | |
// Get user data. | |
$user_data = get_userdata( $user_id ); | |
// Add new post here. | |
wp_insert_post( array( | |
'post_title' => wp_strip_all_tags( sprintf( 'User %s has Joined %s', $user_data->user_login, get_bloginfo('name') ) ), | |
'post_content' => 'Testing auto post creation.', | |
'post_status' => 'draft', | |
'post_author' => $user_id, | |
'post_category' => array(1), | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment