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