wp_install_defaults example


function install_blog_defaults( $blog_id$user_id ) {
    global $wpdb;

    _deprecated_function( __FUNCTION__, 'MU' );

    require_once ABSPATH . 'wp-admin/includes/upgrade.php';

    $suppress = $wpdb->suppress_errors();

    wp_install_defaults( $user_id );

    $wpdb->suppress_errors( $suppress );
}

/** * Update the status of a user in the database. * * Previously used in core to mark a user as spam or "ham" (not spam) in Multisite. * * @since 3.0.0 * @deprecated 5.3.0 Use wp_update_user() * @see wp_update_user() * * @global wpdb $wpdb WordPress database abstraction object. * * @param int $id The user ID. * @param string $pref The column in the wp_users table to update the user's status * in (presumably user_status, spam, or deleted). * @param int $value The new status for the user. * @param null $deprecated Deprecated as of 3.0.2 and should not be used. * @return int The initially passed $value. */
$message = __( 'User already exists. Password inherited.' );
        }

        $user = new WP_User( $user_id );
        $user->set_role( 'administrator' );

        if ( $user_created ) {
            $user->user_url = $guessurl;
            wp_update_user( $user );
        }

        wp_install_defaults( $user_id );

        wp_install_maybe_enable_pretty_permalinks();

        flush_rewrite_rules();

        wp_new_blog_notification( $blog_title$guessurl$user_id( $email_password ? $user_password : __( 'The password you chose during installation.' ) ) );

        wp_cache_flush();

        /** * Fires after a site is fully installed. * * @since 3.9.0 * * @param WP_User $user The site owner. */
$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'] );

    // Set the site administrator.     add_user_to_blog( $site->id, $args['user_id'], 'administrator' );
    if ( ! user_can( $args['user_id'], 'manage_network' ) && ! get_user_meta( $args['user_id'], 'primary_blog', true ) ) {
        update_user_meta( $args['user_id'], 'primary_blog', $site->id );
    }

    if ( $switch ) {
        restore_current_blog();
    }

    
Home | Imprint | This part of the site doesn't use cookies.