Skip to content

Instantly share code, notes, and snippets.

@vladfil
Last active September 13, 2018 08:41
Show Gist options
  • Select an option

  • Save vladfil/4bc76eadc60d6b7928f36d354a722b6b to your computer and use it in GitHub Desktop.

Select an option

Save vladfil/4bc76eadc60d6b7928f36d354a722b6b to your computer and use it in GitHub Desktop.
function create_new_user_posts($user_id){
if (!$user_id>0)
return;
//here we know the user has been created so to create
//3 posts we call wp_insert_post 3 times.
// Create post object
$travel = array(
'post_title' => 'Travel',
'post_status' => 'buddydrive_private',
'post_author' => $user_id,
'post_type' => 'buddydrive-folder'
);
// Insert the post into the database
$travel_item = wp_insert_post( $travel );
$other = array(
'post_title' => 'Other',
'post_status' => 'buddydrive_private',
'post_author' => $user_id,
'post_type' => 'buddydrive-folder'
);
// Insert the post into the database
$other_item = wp_insert_post( $other );
$timesheets = array(
'post_title' => 'Timesheets',
'post_status' => 'buddydrive_private',
'post_author' => $user_id,
'post_type' => 'buddydrive-folder'
);
// Insert the post into the database
$timesheets_item = wp_insert_post( $timesheets );
$personal = array(
'post_title' => 'Personal information',
'post_status' => 'buddydrive_private',
'post_author' => $user_id,
'post_type' => 'buddydrive-folder'
);
// Insert the post into the database
$personal_item = wp_insert_post( $personal );
//and if you want to store the post ids in
//the user meta then simply use update_user_meta
update_user_meta($user_id,'_bio_post',$travel_item);
update_user_meta($user_id,'_portfolio_post',$other_item);
update_user_meta($user_id,'_contact_post',$timesheets_item);
update_user_meta($user_id,'_contact_post',$personal_item);
}
add_action('user_register','create_new_user_posts');
//BuddyPress + Buddydrive - плагины
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment