Last active
October 25, 2015 08:40
-
-
Save danfisher85/8de057043edf6981bd3b to your computer and use it in GitHub Desktop.
[WP Job Manager] Add jobs column to the user admin page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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