Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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 );
 
PREVIOUS NEXT
Tagged: #add #custom #user #meta #display #user #page
ADD COMMENT
Topic
Name
2+6 =