Last active
May 22, 2017 22:00
-
-
Save tripflex/68acbed4d1b3342ae3b73edd2456ec35 to your computer and use it in GitHub Desktop.
WP Job Manager set custom post status on submit based on user role (auto approve for specific user roles)
This file contains 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
<?php | |
add_filter( 'submit_job_post_status', 'smyles_set_job_post_status_by_user_role', 10, 2 ); | |
/** | |
* Automatically set Job post status based on current user's role | |
* | |
* @param $status | |
* @param $job | |
* | |
* @return string | |
*/ | |
function smyles_set_job_post_status_by_user_role( $status, $job ) { | |
if ( ! $user = wp_get_current_user() ) { | |
return $status; | |
} | |
// Replace 'administrator' with any custom or other default role to check against | |
if ( in_array( 'administrator', (array) $user->roles ) ) { | |
return 'publish'; | |
} | |
// Return passed status | |
return $status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's code for setting status based on total user posts:
https://gist.github.com/tripflex/3e07a0bef89eaaeb901e21f2c384b054