delete_metadata example

array(
                    'key'    => $name,
                    'status' => rest_authorization_required_code(),
                )
            );
        }

        if ( null === get_metadata_raw( $meta_type$object_idwp_slash( $meta_key ) ) ) {
            return true;
        }

        if ( ! delete_metadata( $meta_type$object_idwp_slash( $meta_key ) ) ) {
            return new WP_Error(
                'rest_meta_database_error',
                __( 'Could not delete meta value from database.' ),
                array(
                    'key'    => $name,
                    'status' => WP_Http::INTERNAL_SERVER_ERROR,
                )
            );
        }

        return true;
    }

function delete_post_meta( $post_id$meta_key$meta_value = '' ) {
    // Make sure meta is deleted from the post, not from a revision.     $the_post = wp_is_post_revision( $post_id );
    if ( $the_post ) {
        $post_id = $the_post;
    }

    return delete_metadata( 'post', $post_id$meta_key$meta_value );
}

/** * Retrieves a post meta field for the given post ID. * * @since 1.5.0 * * @param int $post_id Post ID. * @param string $key Optional. The meta key to retrieve. By default, * returns data for all keys. Default empty. * @param bool $single Optional. Whether to return a single value. * This parameter has no effect if `$key` is not specified. * Default false. * @return mixed An array of values if `$single` is false. * The value of the meta field if `$single` is true. * False for an invalid `$post_id` (non-numeric, zero, or negative value). * An empty string if a valid but non-existing post ID is passed. */

function delete_user_meta( $user_id$meta_key$meta_value = '' ) {
    return delete_metadata( 'user', $user_id$meta_key$meta_value );
}

/** * Retrieves user meta field for a user. * * @since 3.0.0 * * @link https://developer.wordpress.org/reference/functions/get_user_meta/ * * @param int $user_id User ID. * @param string $key Optional. The meta key to retrieve. By default, * returns data for all keys. * @param bool $single Optional. Whether to return a single value. * This parameter has no effect if `$key` is not specified. * Default false. * @return mixed An array of values if `$single` is false. * The value of meta data field if `$single` is true. * False for an invalid `$user_id` (non-numeric, zero, or negative value). * An empty string if a valid but non-existing user ID is passed. */

function delete_comment_meta( $comment_id$meta_key$meta_value = '' ) {
    return delete_metadata( 'comment', $comment_id$meta_key$meta_value );
}

/** * Retrieves comment meta field for a comment. * * @since 2.9.0 * * @link https://developer.wordpress.org/reference/functions/get_comment_meta/ * * @param int $comment_id Comment ID. * @param string $key Optional. The meta key to retrieve. By default, * returns data for all keys. Default empty string. * @param bool $single Optional. Whether to return a single value. * This parameter has no effect if `$key` is not specified. * Default false. * @return mixed An array of values if `$single` is false. * The value of meta data field if `$single` is true. * False for an invalid `$comment_id` (non-numeric, zero, or negative value). * An empty string if a valid but non-existing comment ID is passed. */

function delete_term_meta( $term_id$meta_key$meta_value = '' ) {
    return delete_metadata( 'term', $term_id$meta_key$meta_value );
}

/** * Retrieves metadata for a term. * * @since 4.4.0 * * @param int $term_id Term ID. * @param string $key Optional. The meta key to retrieve. By default, * returns data for all keys. Default empty. * @param bool $single Optional. Whether to return a single value. * This parameter has no effect if `$key` is not specified. * Default false. * @return mixed An array of values if `$single` is false. * The value of the meta field if `$single` is true. * False for an invalid `$term_id` (non-numeric, zero, or negative value). * An empty string if a valid but non-existing term ID is passed. */

    protected function destroy_all_sessions() {
        $this->update_sessions( array() );
    }

    /** * Destroys all sessions for all users. * * @since 4.0.0 */
    public static function drop_sessions() {
        delete_metadata( 'user', 0, 'session_tokens', false, true );
    }
}
    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'] );

    // 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 ( get_site_option( 'ms_files_rewriting' ) ) {
        update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
    } else {
        update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
    }

    update_option( 'blogname', wp_unslash( $blog_title ) );
    update_option( 'admin_email', '' );

    // Remove all permissions.     $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. }

/** * Set blog defaults. * * This function creates a row in the wp_blogs table. * * @since MU (3.0.0) * @deprecated MU * @deprecated Use wp_install_defaults() * * @global wpdb $wpdb WordPress database abstraction object. * * @param int $blog_id Ignored in this function. * @param int $user_id */
Home | Imprint | This part of the site doesn't use cookies.