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 :: php case switch 
Php :: test if php is installed 
Php :: how to force delete in laravel 8 
Php :: how to redirect to another page from laravel blade 
Php :: get all artisan commands 
Php :: laravel validate file type 
Php :: laravel old request radio check 
Php :: wordpress truncate text 
Php :: php syntax 
Php :: how to find this day is holiday in php day 
Php :: laravel form validation 
Php :: php get current time and date 
Php :: laravel model is dirty 
Php :: return last inserted id in laravel 
Php :: how to get last executed query in laravel 
Php :: how to add data to an object in php 
Php :: laravel echo query 
Php :: mysqli loop 
Php :: php array merge skip diplicate 
Php :: redirect back with input laravel in request 
Php :: laravel pagination with get parameters 
Php :: php counter 
Php :: set session after login with laravel 
Php :: var dump php look clear 
Php :: csv to array php 
Php :: php requuire once 
Php :: php convert object to array nested 
Php :: laravel subtract date 
Php :: how to get current location in laravel 
Php :: php remove duplicates from multidimensional array 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =