Skip to content

Instantly share code, notes, and snippets.

@tripflex
Last active May 22, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/68acbed4d1b3342ae3b73edd2456ec35 to your computer and use it in GitHub Desktop.
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)
<?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;
}
@tripflex
Copy link
Author

Here's code for setting status based on total user posts:

https://gist.github.com/tripflex/3e07a0bef89eaaeb901e21f2c384b054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment