delete_user_meta example

/** * Updates the user's sessions in the usermeta table. * * @since 4.0.0 * * @param array $sessions Sessions. */
    protected function update_sessions( $sessions ) {
        if ( $sessions ) {
            update_user_meta( $this->user_id, 'session_tokens', $sessions );
        } else {
            delete_user_meta( $this->user_id, 'session_tokens' );
        }
    }

    /** * Destroys all sessions for this user, except the single session with the given verifier. * * @since 4.0.0 * * @param string $verifier Verifier of the session to keep. */
    protected function destroy_other_sessions( $verifier ) {
        
// Execute confirmed email change. See send_confirmation_on_profile_email(). if ( IS_PROFILE_PAGE && isset( $_GET['newuseremail'] ) && $current_user->ID ) {
    $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    if ( $new_email && hash_equals( $new_email['hash']$_GET['newuseremail'] ) ) {
        $user             = new stdClass();
        $user->ID         = $current_user->ID;
        $user->user_email = esc_html( trim( $new_email['newemail'] ) );
        if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
            $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
        }
        wp_update_user( $user );
        delete_user_meta( $current_user->ID, '_new_email' );
        wp_redirect( add_query_arg( array( 'updated' => 'true' )self_admin_url( 'profile.php' ) ) );
        die();
    } else {
        wp_redirect( add_query_arg( array( 'error' => 'new-email' )self_admin_url( 'profile.php' ) ) );
    }
} elseif ( IS_PROFILE_PAGE && ! empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) {
    check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' );
    delete_user_meta( $current_user->ID, '_new_email' );
    wp_redirect( add_query_arg( array( 'updated' => 'true' )self_admin_url( 'profile.php' ) ) );
    die();
}


function delete_user_option( $user_id$option_name$is_global = false ) {
    global $wpdb;

    if ( ! $is_global ) {
        $option_name = $wpdb->get_blog_prefix() . $option_name;
    }

    return delete_user_meta( $user_id$option_name );
}

/** * Retrieves list of users matching criteria. * * @since 3.1.0 * * @see WP_User_Query * * @param array $args Optional. Arguments to retrieve users. See WP_User_Query::prepare_query() * for more information on accepted arguments. * @return array List of users. */
/** * Removes all of the capabilities of the user. * * @since 2.1.0 * * @global wpdb $wpdb WordPress database abstraction object. */
    public function remove_all_caps() {
        global $wpdb;
        $this->caps = array();
        delete_user_meta( $this->ID, $this->cap_key );
        delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' );
        $this->get_role_caps();
    }

    /** * Returns whether the user has the specified capability. * * This function also accepts an ID of an object to check against if the capability is a meta capability. Meta * capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to * map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`. * * Example usage: * * $user->has_cap( 'edit_posts' ); * $user->has_cap( 'edit_post', $post->ID ); * $user->has_cap( 'edit_post_meta', $post->ID, $meta_key ); * * While checking against a role in place of a capability is supported in part, this practice is discouraged as it * may produce unreliable results. * * @since 2.0.0 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter * by adding it to the function signature. * * @see map_meta_cap() * * @param string $cap Capability name. * @param mixed ...$args Optional further parameters, typically starting with an object ID. * @return bool Whether the user has the given capability, or, if an object ID is passed, whether the user has * the given capability for that object. */
Home | Imprint | This part of the site doesn't use cookies.