Will McLean is a designer and artist working in the Central Coast of NSW where he lives with his wife and 2 children.

Will draws and paints out of habit and addiction. He writes about his struggles on the battlefield of art in the Art Archive section of this site.

Will is a meticulous developer and favours simplicity and clarity within his code. He can’t stand writing things twice so searches for any way to automate. His experiments can be found in the Exercises section of this site.

Will designs within systems. No project is too small for a design system. He favours the unusual, if not, how can he progress? You can read about his work in the Case Studies section of this site.

Updated: October 31, 2017

This is a Knowledge Base post.

Stop users adding terms to a taxonomy

I used this to stop anyone adding terms to a taxonomy that we needed to be set to a set of specific terms. Once they were added to the databases across all environments the below was added to the functions file.


add_action( 'pre_insert_term', 'prevent_terms', 1, 2 );
function prevent_terms ( $term, $taxonomy ) {
    if ( 'term_name' === $taxonomy ) { // You could add more conditionals here based on the user permissions
        return new WP_Error( 'term_addition_blocked', __( 'You cannot add terms to this taxonomy' ) );
    }
 
    return $term;
}

Make sure you update the term_name.

I have lost the source for this, sorry.