Search
 
SCRIPT & CODE EXAMPLE
 

PHP

add custom user meta and display it in user page

function yoursite_manage_users_columns( $columns ) {

    // $columns is a key/value array of column slugs and names
    $columns[ 'custom_field' ] = 'Subscription';

    return $columns;
}

add_filter( 'manage_users_columns', 'yoursite_manage_users_columns', 10, 1 );

function yoursite_manage_users_custom_column( $output, $column_key, $user_id ) {

    switch ( $column_key ) {
        case 'custom_field':
            $value = get_user_meta( $user_id, 'custom_field', true );

            return $value;
            break;
        default: break;
    }

    // if no column slug found, return default output value
    return $output;
}

add_action( 'manage_users_custom_column', 'yoursite_manage_users_custom_column', 10, 3 );
Comment

add user meta

<?php
	add_user_meta($user_id, $meta_key, $meta_value, $unique);
?>
Comment

PREVIOUS NEXT
Code Example
Php :: read global laravel request() 
Php :: wpdb-prepare 
Php :: PHP strtoupper() Function 
Php :: strtotime add 1 hour 
Php :: laravel check if table has column 
Php :: pdo bindparam string 
Php :: php object foreach 
Php :: render vs redirect laravel exception 
Php :: php date is before 
Php :: Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, bool given in C: ewxammphtdocslearnindex.php on line 11 
Php :: post type taxonomy loop wordpress 
Php :: random string php 
Php :: nl2br php 
Php :: how login with phone in laravel 
Php :: where_in codeigniter 
Php :: get header respnse code php curl 
Php :: update onlu one column laravel 
Php :: Fatal error: Cannot redeclare 
Php :: php pi() function 
Php :: how to publish stubs in laravel 
Php :: how to add recaptcha to woocommerce register php 
Php :: php random string 
Php :: laravel migration remove relationship from table 
Php :: php curl asyc 
Php :: how to save file in storage folder in laravel 
Php :: php echo array 
Php :: get file name from url in php 
Php :: PHP get_url 
Php :: linux delete php sessions 
Php :: In PackageManifest.php line 122: 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =