for_site example



        $role__not_in = array();
        if ( isset( $qv['role__not_in'] ) ) {
            $role__not_in = (array) $qv['role__not_in'];
        }

        // Capabilities.         $available_roles = array();

        if ( ! empty( $qv['capability'] ) || ! empty( $qv['capability__in'] ) || ! empty( $qv['capability__not_in'] ) ) {
            $wp_roles->for_site( $blog_id );
            $available_roles = $wp_roles->roles;
        }

        $capabilities = array();
        if ( ! empty( $qv['capability'] ) ) {
            if ( is_array( $qv['capability'] ) ) {
                $capabilities = $qv['capability'];
            } elseif ( is_string( $qv['capability'] ) ) {
                $capabilities = array_map( 'trim', explode( ',', $qv['capability'] ) );
            }
        }

        

function wp_switch_roles_and_user( $new_site_id$old_site_id ) {
    if ( $new_site_id == $old_site_id ) {
        return;
    }

    if ( ! did_action( 'init' ) ) {
        return;
    }

    wp_roles()->for_site( $new_site_id );
    wp_get_current_user()->for_site( $new_site_id );
}

/** * Determines if switch_to_blog() is in effect. * * @since 3.5.0 * * @global array $_wp_switched_stack * * @return bool True if switched, false otherwise. */

    public function __construct( $site_id = null ) {
        global $wp_user_roles;

        $this->use_db = empty( $wp_user_roles );

        $this->for_site( $site_id );
    }

    /** * Makes private/protected methods readable for backward compatibility. * * @since 4.0.0 * * @param string $name Method to call. * @param array $arguments Arguments to pass when calling. * @return mixed|false Return value of the callback, false otherwise. */
    

    public function init( $data$site_id = '' ) {
        if ( ! isset( $data->ID ) ) {
            $data->ID = 0;
        }
        $this->data = $data;
        $this->ID   = (int) $data->ID;

        $this->for_site( $site_id );
    }

    /** * Returns only the main user fields. * * @since 3.3.0 * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter. * * @global wpdb $wpdb WordPress database abstraction object. * * @param string $field The field to query against: 'id', 'ID', 'slug', 'email' or 'login'. * @param string|int $value The field value. * @return object|false Raw user object. */
Home | Imprint | This part of the site doesn't use cookies.