您应该记住的一件事是该函数,它将连接到manage_users_custom_column
行动must have 3 parameters, 第一个(即。$val
) 应为返回值:
// Add custom column using \'manage_users_columns\' filter
if(!function_exists(\'bm_utm_column\')){
function bm_utm_column($columns) {
return array_merge( $columns,
array(\'utm_source\' => __(\'UTM source\'),
\'utm_medium\' => __(\'UTM medium\')
)
);
}
}
// Add the content from usermeta\'s table by using \'manage_users_custom_column\' hook
if(!function_exists(\'bm_utm_column_value\')){
function bm_utm_column_value($val, $column_name, $user_id) {
if ( \'utm_source\' == $column_name ) {
//Custom value
$val = get_user_meta($user_id, \'utm_source\', true);
}
if ( \'utm_medium\' == $column_name ) {
//Custom value
$val = get_user_meta($user_id, \'utm_medium\', true);
}
return $val;
}
}
// Hook into filter
add_filter( \'manage_users_columns\', \'bm_utm_column\' );
add_action( \'manage_users_custom_column\', \'bm_utm_column_value\', 10, 3 );