Created
February 8, 2019 07:41
-
-
Save yousufansa/fe2d8e56886ec2effbf867e01f081487 to your computer and use it in GitHub Desktop.
Jobhunt - Add Posted Jobs Count In Admin User Table
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
| if ( ! function_exists( 'jh_child_add_user_table_column' ) ) { | |
| function jh_child_add_user_table_column( $column ) { | |
| if ( post_type_exists( 'job_listing' ) ) { | |
| $column['jobs'] = esc_html__( 'Jobs', 'jobhunt-child' ); | |
| } | |
| return $column; | |
| } | |
| } | |
| add_filter( 'manage_users_columns', 'jh_child_add_user_table_column' ); | |
| if ( ! function_exists( 'jh_child_add_user_table_row' ) ) { | |
| function jh_child_add_user_table_row( $val, $column_name, $user_id ) { | |
| if ( post_type_exists( 'job_listing' ) ) { | |
| switch ($column_name) { | |
| case 'jobs' : | |
| if( count_user_posts( $user_id , 'job_listing' ) > 0 ) { | |
| $count_user_jobs = '<a href="' . admin_url() . 'edit.php?post_type=job_listing&author=' . $user_id . '">' . count_user_posts( $user_id , 'job_listing' ) . '</a>'; | |
| } else { | |
| $count_user_jobs = count_user_posts( $user_id , 'job_listing' ); | |
| } | |
| return $count_user_jobs; | |
| break; | |
| default: | |
| } | |
| } | |
| return $val; | |
| } | |
| } | |
| add_filter( 'manage_users_custom_column', 'jh_child_add_user_table_row', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment