add_user_to_blog
最后更新于:2021-11-25 19:22:47
do_action( ‘add_user_to_blog’, int $user_id, string $role, int $blog_id )
Fires immediately after a user is added to a site.
参数
- $user_id
-
(int)
User ID. - $role
-
(string)
User role. - $blog_id
-
(int)
Blog ID.
源文件
文件: gc-includes/ms-functions.php
/** * Add a user to network sites. * * @param int $user_id User ID. */ function gcdocs_add_user_to_network_sites( $user_id ) { // Put common sites here $blogs = array( 1, 2, 3, 5,8 ); foreach ( $blogs as $blog ) { add_user_to_blog( $user_id, $blog, 'subscriber' ); } } add_action( 'user_register', 'gcdocs_add_user_to_network_sites' );