Created
August 24, 2021 00:09
-
-
Save tripflex/4a716156576628b939ffa640cd56cb9b to your computer and use it in GitHub Desktop.
Remove specific fields from submit form based on current user role when using WP Job Manager Field Editor
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_form_fields', 'smyles_remove_fields_by_user_role', 999999999999 ); | |
function smyles_remove_fields_by_user_role( $fields ){ | |
$fields_to_remove = array( 'job_salary', 'some_other_meta_key' ); | |
$user = wp_get_current_user(); | |
if ( in_array( 'employer', (array) $user->roles ) ) { | |
foreach( $fields_to_remove as $meta_key ){ | |
if( isset( $fields['job'][ $meta_key ] ) ){ | |
unset( $fields['job'][ $meta_key ] ); | |
} | |
} | |
} | |
return $fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment