I need to hook to the users list page.
I Need to add a checkbox column for each user to remember if they have paid or not.
Thanks for help because can’t find snippet to hook to this admin page.
I need to hook to the users list page.
I Need to add a checkbox column for each user to remember if they have paid or not.
Thanks for help because can’t find snippet to hook to this admin page.
One thing you should remember is that function, which will be hooked into manage_users_custom_column
action must have 3 parameters, the first of which (i.e. $val
) should be the returned value:
// 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 );