WP_Roles example


    $wpdb->suppress_errors( $suppress );

    $url = get_blogaddress_by_id( $blog_id );

    // Set everything up.     make_db_current_silent( 'blog' );
    populate_options();
    populate_roles();

    // populate_roles() clears previous role definitions so we start over.     $wp_roles = new WP_Roles();

    $siteurl = $home = untrailingslashit( $url );

    if ( ! is_subdomain_install() ) {

        if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
            $siteurl = set_url_scheme( $siteurl, 'https' );
        }
        if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
            $home = set_url_scheme( $home, 'https' );
        }
    }

$GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();

/** * WordPress User Roles * * @global WP_Roles $wp_roles WordPress role management object. * @since 2.0.0 */
$GLOBALS['wp_roles'] = new WP_Roles();

/** * Fires before the theme is loaded. * * @since 2.6.0 */
do_action( 'setup_theme' );

// Define the template related constants. wp_templating_constants();

'WPLANG'      => get_network_option( $network->id, 'WPLANG' ),
            ),
            $args['options']
        )
    );

    // Clean blog cache after populating options.     clean_blog_cache( $site );

    // Populate the site's roles.     populate_roles();
    $wp_roles = new WP_Roles();

    // Populate metadata for the site.     populate_site_meta( $site->id, $args['meta'] );

    // Remove all permissions that may exist for the site.     $table_prefix = $wpdb->get_blog_prefix();
    delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true );   // Delete all.     delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all.
    // Install default site content.     wp_install_defaults( $args['user_id'] );

    

function wp_roles() {
    global $wp_roles;

    if ( ! isset( $wp_roles ) ) {
        $wp_roles = new WP_Roles();
    }
    return $wp_roles;
}

/** * Retrieves role object. * * @since 2.0.0 * * @param string $role Role name. * @return WP_Role|null WP_Role object if found, null if the role does not exist. */
Home | Imprint | This part of the site doesn't use cookies.