Automatically create a post on user first login
-
Hi guys,
Is there a way how to create a post on user first login?
Currently i have a code which automatically creates a post when user registers on the site, but i want to change it so the post is created only if user is approved and logged in first time. This is the code which i used so far:function my_create_page($user_id){
$the_user = get_userdata($user_id);
$new_user_name = $the_user->user_login;
$new_user_id = $the_user->ID;
$shop_name = $the_user->tds_shop_name;$my_post = array();
$my_post[‘post_title’] = $shop_name;
$my_post[‘post_author’] = $new_user_id;
$my_post[‘post_type’] = ‘business’;
$my_post[‘post_content’] = ”;
$my_post[‘post_status’] = ‘private’;
wp_insert_post( $my_post );
}
add_action(‘user_register’, ‘my_create_page’);Thanks!
- The topic ‘Automatically create a post on user first login’ is closed to new replies.