admin管理员组文章数量:1415070
I'm using a plugin that is not built for multisite: Restrict Content Pro Group Accounts.
Now, before it adds a member to a group, it checks if they are already part of a group and gives an error message.
The code it uses is:
if ( rcpga_group_accounts()->members->get_group_id( $user_id ) ) {
return new WP_Error( 'has-group', __( 'This user is already in a group. Users may only be part of one group at a time.', 'rcp-group-account' ) );
}
Currently, it only check if the user has an account on the current subsite, and not through the whole network.
I want to extend it to prevent a user on any subsite in the multisite network from being added to a group.
So I took the function above and rewrote it as follows:
$blogs_user = get_blogs_of_user( $user_id );
if ( (rcpga_group_accounts()->members->get_group_id( $user_id )) || (count($blogs_user)>0) ) {
return new WP_Error( 'has-group', __( 'This user is already in a group. Users may only be part of one group at a time.', 'rcp-group-account' ) );
}
I'm trying to check if the user is a member of any site on the network. If they are, then it means they already have an account, and so an error should be thrown.
My code doesn't work however, and gets triggered even when adding a new user that is not on any site in the network.
What am I doing wrong?
本文标签: pluginsHow to use getblogsofuser
版权声明:本文标题:plugins - How to use get_blogs_of_user? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745232158a2648872.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论