Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function disallow_insert_term($term, $taxonomy) {
- $user = wp_get_current_user();
- error_log("{$term, $taxonomy}"); //inspect term and taxonomy
- error_log(implode(', ', $user->roles); //inspect the user roles
- if ( $taxonomy === 'post_tag' && in_array('somerole', $user->roles) ) {
- error_log('yes, disallow this term...'); //do we get into the conditional
- return new WP_Error(
- 'disallow_insert_term',
- __('Your role does not have permission to add terms to this taxonomy')
- );
- }
- }
- add_action( 'pre_insert_term', 'disallow_insert_term', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement