Add custom column on wp admin
xxxxxxxxxx
function new_modify_user_table( $column ) {
$column['refer_points'] = 'Referral points';
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 'refer_points' :
return get_the_author_meta( 'refer_points', $user_id );
default:
}
return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
xxxxxxxxxx
add_filter( 'manage_edit-product_columns','mishafunction' ,999);
add_filter( 'manage_product_posts_custom_column','misha_populate_columns', 1000, 2);
function mishafunction( $columns ){
// do something with $columns array
$data['custom_price'] = 'i3woo Cost';
$columns = $this->insertArrayAtPosition($columns,$data,7);
return $columns;
}
function insertArrayAtPosition( $array, $insert, $position ) {
/*
$array : The initial array i want to modify
$insert : the new array i want to add, eg array('key' => 'value') or array('value')
$position : the position where the new array will be inserted into. Please mind that arrays start at 0
*/
return array_slice($array, 0, $position, TRUE) + $insert + array_slice($array, $position, NULL, TRUE);
}
function misha_populate_columns( $column_name, $post_id) {
// $id is the User ID or taxonomy Term ID
if( $column_name == 'custom_price' ) { // you can use switch()
// do something and write the result into $output
echo 'hello i am output';
}
}