Force Contributors to add Tags via edit-tags.php


I need to be able to stop contributors to the website from adding new Tags when they create or edit a Post in WP.

The reason is that I need them to enter an additional field at the same time which I can achieve via ACF in the edit-tags.php page.

However, no matter what I do I can’t seem to stop users entering new tags on the tag section on the new post or edit post page(s). They should still be able to select from existing tags when creating/editing a post, but to enter one they should be forced to use the edit-tags.php.

Here’s what I’ve got so far:

function disallow_insert_term($term, $taxonomy) {
  if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') ) {
    return new WP_Error(
      __('Your role does not have permission to add terms to this taxonomy')
  } elseif (strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit-tags.php')) {
      return $term;
add_filter('pre_insert_term', 'disallow_insert_term', 10, 2);

The problem is that any new “if” tests I try to do within the function end up being ignored and just the final task runs. So, in the above, the user can enter new tags on any page. If I remove the “elseif” function you can’t enter any tags into the site at all.

I’ve tried using get_current_screen() and $wp->request to get the URL but just run into the same problem.


>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="">

Force Contributors to add Tags via edit-tags.php</a>
, kubo 3 months 0 Answers 65 views 0

Leave an answer