最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how to add custom culomn to add user wordpress in plugin

programmeradmin1浏览0评论

I want to add a custom column called balance for each user and I want to be able to update this column by adding value or subtracting value from it, and I want to do that by a plugin I create, any ideas ??

I used this code but the balance field doesn't show when I want to add a new user

  '<?php 
/**
 * Plugin Name: add_col
 * Description : plugin adds new column to user info
 */
 
 function new_contact_methods( $contactmethods ) {
    $contactmethods['balance'] = 'balance';
    return $contactmethods;
}
add_filter( 'user_contactmethods', 'new_contact_methods', 10, 1 );


function new_modify_user_table( $column ) {
    $column['balance'] = 'balance';
    return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );

function new_modify_user_table_row( $val, $column_name, $user_id ) {
    switch ($column_name) {
        case 'balance' :
            return get_the_author_meta( 'balance', $user_id );
        default:
    }
    return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

'

发布评论

评论列表(0)

  1. 暂无评论