首先,听起来您可以使用BuddyPress.
如果您只想在用户注册时创建一个实际的WordPress页面,您可以使用user_register
钩钩子接收新创建的用户ID。
此代码示例应创建一个包含用户nicename
.
add_action( \'user_register\', \'myplugin_add_page_for_user\' );
function myplugin_add_page_for_user( $user_id ) {
// Get the user for this user_id
$user = get_user_by( \'id\', $user_id );
// The data for the page we are going to add
$page_data = array(
\'post_type\' => \'page\',
\'post_title\' => $user->user_nicename
);
// Actually insert the post
wp_insert_post( $page_data );
}