• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

On my website I want to disallow the creation of new tags when writing a blog post. I am using the classic editor and a custom theme on WordPress 5.x.

I found the following code snipped which seems to work okay, but I have two problems.

    // disable creating of new tags     add_action( 'pre_insert_term', function($Term, $Taxonomy) {             return ($Taxonomy === 'post_tag')                     ? new WP_Error( 'term_addition_blocked', __( 'You are unauthorized to add new terms.' ) )                     : $Term;     }, 0, 2 ); 

(1) Users can still enter any word into the tag input. When the post is saved, tags that don't exist are not saved. This is kind of confusing as it looks like users are still able to add any tag they want.

(2) If a user selects a correct tag and then adds an incorrect one it will save the correct one, but if the users adds an incorrect one first and then a correct one it drops them both.

Can anyone point me into the right direction? I am happy to install a plugin or add custom code to functions.php to change how users can assign tags to posts.

Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]