There is the action hook user_register
that is called immediately after a user is added to the database. The user id is passed to the hook as an argument.
You can use wp_insert_post
to insert a new post in that action. You just need to get the relevant info from the user and add it to the post. You can add custom fields to the post you create by referencing the post ID that is returned by wp_insert_post
.
This is an example of how you would add a custom post type post on user registration – you’ll obviously need to change it to fit your needs, but it should give you an idea of what to do.
/*
* Create new custom post type post on new user registration
*/
add_action( 'user_register', 'wpse_216921_company_cpt', 10, 1 );
function wpse_216921_company_cpt( $user_id )
{
// Get user info
$user_info = get_userdata( $user_id );
// Create a new post
$user_post = array(
'post_title' => $user_info->nickname;
'post_content' => $user_info->description,
'post_type' => 'your_company_custom_post_type', // <- change to your cpt
);
// Insert the post into the database
$post_id = wp_insert_post( $user_post );
// Add custom company info as custom fields
add_post_meta( $post_id, 'company_id', $user_info->ID );
add_post_meta( $post_id, 'company_email', $user_info->user_email );
}