如果您没有确认电子邮件,但必须挂接激活才能使用add_user_to_blog. 如果您提供两个元数据字段,WordPress将在用户激活时向现有博客(现在称为网站)添加用户:
<?php
$user_blog_id = 2; // or get_current_blog_id(), etc.
$user_meta = [
\'add_to_blog\' => $user_blog_id,
\'new_role\' => \'subscriber\' // or any other role your site has...
];
// WordPress has a built-in action on activation to look
// for the above fields and assign the user to a
// given blog id (network site) and role.
\\wpmu_signup_user( $user_name, $user_email, apply_filters( \'add_signup_meta\', $user_meta ) );
看见
add_new_user_to_blog 更多信息(这是通过用户激活操作调用的函数,该操作使用上述示例中的元字段将用户分配到博客[网站])。