Skip to content

Instantly share code, notes, and snippets.

@danfisher85
Last active October 25, 2015 08:40
Show Gist options
  • Save danfisher85/8de057043edf6981bd3b to your computer and use it in GitHub Desktop.
Save danfisher85/8de057043edf6981bd3b to your computer and use it in GitHub Desktop.
[WP Job Manager] Add jobs column to the user admin page
/*
* Add Jobs Column
*/
function users_job_listings_column( $cols ) {
$cols['user_job_listings'] = __('Jobs', 'petsitter');
return $cols;
}
/*
* Print Jobs Column Value
*/
function user_job_listings_column_value( $value, $column_name, $id ) {
if( $column_name == 'user_job_listings' ) {
global $wpdb;
$count = (int) $wpdb->get_var( $wpdb->prepare(
"SELECT COUNT(ID) FROM $wpdb->posts WHERE
post_type = 'job_listing' AND post_status = 'publish' AND post_author = %d",
$id
) );
return $count;
}
}
add_filter( 'manage_users_custom_column', 'user_job_listings_column_value', 10, 3 );
add_filter( 'manage_users_columns', 'users_job_listings_column' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment