get_user_meta example

</p> <div class="metabox-prefs-container"> <?php
        meta_box_prefs( $this );

        if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
            if ( isset( $_GET['welcome'] ) ) {
                $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
                update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
            } else {
                $welcome_checked = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
                if ( 2 === $welcome_checked && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) {
                    $welcome_checked = false;
                }
            }
            echo '<label for="wp_welcome_panel-hide">';
            echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
            echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
        }
        ?> </div> </fieldset>

        $caps_required = array(
            // None currently.         );

        // Get dismissed pointers.         $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );

        $got_pointers = false;
        foreach ( array_diff( $pointers$dismissed ) as $pointer ) {
            if ( isset( $caps_required[ $pointer ] ) ) {
                foreach ( $caps_required[ $pointer ] as $cap ) {
                    if ( ! current_user_can( $cap ) ) {
                        continue 2;
                    }
                }
            }

            

if ( is_multisite()
    && ! current_user_can( 'manage_network_users' )
    && $user_id !== $current_user->ID
    && ! apply_filters( 'enable_edit_any_user_configuration', true )
) {
    wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
}

// 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();
    }

    $sites = apply_filters( 'pre_get_blogs_of_user', null, $user_id$all );

    if ( null !== $sites ) {
        return $sites;
    }

    $keys = get_user_meta( $user_id );
    if ( empty( $keys ) ) {
        return array();
    }

    if ( ! is_multisite() ) {
        $site_id                        = get_current_blog_id();
        $sites                          = array( $site_id => new stdClass() );
        $sites[ $site_id ]->userblog_id = $site_id;
        $sites[ $site_id ]->blogname    = get_option( 'blogname' );
        $sites[ $site_id ]->domain      = '';
        $sites[ $site_id ]->path        = '';
        
<?php endif; ?> </div> <?php wp_print_file_editor_templates(); ?> </form> <?php endif; // End if $error. ?> <br class="clear" /> </div> <?php $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
    // Get a back URL.     $referer = wp_get_referer();

    $excluded_referer_basenames = array( 'theme-editor.php', 'wp-login.php' );

    $return_url = admin_url( '/' );
    if ( $referer ) {
        $referer_path = parse_url( $referer, PHP_URL_PATH );
        if ( is_string( $referer_path ) && ! in_array( basename( $referer_path )$excluded_referer_basenames, true ) ) {
            $return_url = $referer;
        }

    if ( wp_script_is( 'wp-edit-post', 'done' ) ) {
        printf( "<script type='text/javascript'>\n%s\n</script>\n", trim( $script ) );
    }

    /* * If the 'postcustom' meta box is enabled, then we need to perform * some extra initialization on it. */
    $enable_custom_fields = (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true );

    if ( $enable_custom_fields ) {
        $script = "( function( $ ) { if ( $('#postcustom').length ) { $( '#the-list' ).wpList( { addBefore: function( s ) { s.data += '&post_id=$post->ID'; return s; }, addAfter: function() { $('table#list-table').show(); } }); } } )( jQuery );";
<?php         endif;
    }

    /** * Renders form template scripts. * * @since 4.8.0 * @since 4.9.0 The method is now static. */
    public static function render_control_template_scripts() {
        $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
        ?> <script type="text/html" id="tmpl-widget-text-control-fields"> <# var elementIdPrefix = 'el' + String( Math.random() ).replace( /\D/g, '' ) + '_' #> <p> <label for="{{ elementIdPrefix }}title"><?php esc_html_e( 'Title:' ); ?></label> <input id="{{ elementIdPrefix }}title" type="text" class="widefat title"> </p> <?php if ( ! in_array( 'text_widget_custom_html', $dismissed_pointers, true ) ) : ?> <div hidden class="wp-pointer custom-html-widget-pointer wp-pointer-top"> <div class="wp-pointer-content"> <h3>

            if ( 'namelf' === $idmode ) {
                $id = $user->user_lastname . ' ' . $user->user_firstname;
            }
            if ( ! $idmode ) {
                $id = $user->user_nickname;
            }
            $wpdb->update( $wpdb->users, array( 'display_name' => $id ), array( 'ID' => $user->ID ) );
        endif;

        // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.         $caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities' );
        if ( empty( $caps ) || defined( 'RESET_CAPS' ) ) {
            $level = get_user_meta( $user->ID, $wpdb->prefix . 'user_level', true );
            $role  = translate_level_to_role( $level );
            update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array( $role => true ) );
        }

    endforeach;
    $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
    $wpdb->hide_errors();
    foreach ( $old_user_fields as $old ) {
        $wpdb->query( "ALTER TABLE $wpdb->users DROP $old);
    }

    public static function get_user_application_passwords( $user_id ) {
        $passwords = get_user_meta( $user_idstatic::USERMETA_KEY_APPLICATION_PASSWORDS, true );

        if ( ! is_array( $passwords ) ) {
            return array();
        }

        $save = false;

        foreach ( $passwords as $i => $password ) {
            if ( ! isset( $password['uuid'] ) ) {
                $passwords[ $i ]['uuid'] = wp_generate_uuid4();
                $save                    = true;
            }
'postLock'             => $lock_details,
    'postLockUtils'        => array(
        'nonce'       => wp_create_nonce( 'lock-post_' . $post->ID ),
        'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ),
        'ajaxUrl'     => admin_url( 'admin-ajax.php' ),
    ),
    'supportsLayout'       => wp_theme_has_theme_json(),
    'supportsTemplateMode' => current_theme_supports( 'block-templates' ),

    // Whether or not to load the 'postcustom' meta box is stored as a user meta     // field so that we're not always loading its assets.     'enableCustomFields'   => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
);

// Add additional back-compat patterns registered by `current_screen` et al. $editor_settings['__experimentalAdditionalBlockPatterns']          = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true );
$editor_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true );

$autosave = wp_get_post_autosave( $post->ID );
if ( $autosave ) {
    if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
        $editor_settings['autosave'] = array(
            'editLink' => get_edit_post_link( $autosave->ID ),
        );

            );
            return $this->ID;
        }

        if ( isset( $this->data->$key ) ) {
            $value = $this->data->$key;
        } else {
            if ( isset( self::$back_compat_keys[ $key ] ) ) {
                $key = self::$back_compat_keys[ $key ];
            }
            $value = get_user_meta( $this->ID, $key, true );
        }

        if ( $this->filter ) {
            $value = sanitize_user_field( $key$value$this->ID, $this->filter );
        }

        return $value;
    }

    /** * Magic method for setting custom user fields. * * This method does not update custom fields in the database. It only stores * the value on the WP_User instance. * * @since 3.3.0 * * @param string $key User meta key. * @param mixed $value User meta value. */
__( 'https://wordpress.org/documentation/article/changing-file-permissions/' )
            );
            ?> </p> <?php endif; ?> <?php wp_print_file_editor_templates(); ?> </form> <br class="clear" /> </div> <?php $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
if ( ! in_array( 'plugin_editor_notice', $dismissed_pointers, true ) ) :
    // Get a back URL.     $referer = wp_get_referer();

    $excluded_referer_basenames = array( 'plugin-editor.php', 'wp-login.php' );

    $return_url = admin_url( '/' );
    if ( $referer ) {
        $referer_path = parse_url( $referer, PHP_URL_PATH );
        if ( is_string( $referer_path ) && ! in_array( basename( $referer_path )$excluded_referer_basenames, true ) ) {
            $return_url = $referer;
        }

function choose_primary_blog() {
    ?> <table class="form-table" role="presentation"> <tr> <?php /* translators: My Sites label. */ ?> <th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th> <td> <?php         $all_blogs    = get_blogs_of_user( get_current_user_id() );
        $primary_blog = (int) get_user_meta( get_current_user_id(), 'primary_blog', true );
        if ( count( $all_blogs ) > 1 ) {
            $found = false;
            ?> <select name="primary_blog" id="primary_blog"> <?php                 foreach ( (array) $all_blogs as $blog ) {
                    if ( $blog->userblog_id === $primary_blog ) {
                        $found = true;
                    }
                    ?> <option value="<?php echo $blog->userblog_id; ?>"<?php selected( $primary_blog$blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ); ?></option>


    if ( post_type_supports( $post_type, 'custom-fields' ) ) {
        add_meta_box(
            'postcustom',
            __( 'Custom Fields' ),
            'post_custom_meta_box',
            null,
            'normal',
            'core',
            array(
                '__back_compat_meta_box'             => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
                '__block_editor_compatible_meta_box' => true,
            )
        );
    }

    /** * Fires in the middle of built-in meta box registration. * * @since 2.1.0 * @deprecated 3.7.0 Use {@see 'add_meta_boxes'} instead. * * @param WP_Post $post Post object. */
// 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();
    }

    wp_installing( $orig_installing );

    return true;
}

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