1

I'm trying to automatically add a custom taxonomy term to custom post type when the custom post type of property is created. The action is firing but it is not adding the term. I know it is firing because I'm using Debug Bar Action Hooks plugin.

I'm also getting the following errors:

Warning: Missing argument 2 for add_locked_term() in /nas/wp/www/staging/jmoreilly/wp-content/plugins/custom-properties/meta-box.php on line 448

Warning: Missing argument 3 for add_locked_term() in /nas/wp/www/staging/jmoreilly/wp-content/plugins/custom-properties/meta-box.php on line 448

Notice: Undefined variable: post in /nas/wp/www/staging/jmoreilly/wp-content/plugins/custom-properties/meta-box.php on line 449

Notice: Undefined variable: post in /nas/wp/www/staging/jmoreilly/wp-content/plugins/custom-properties/meta-box.php on line 450

This code is in a plugin and it appears that those variables are not yet created at the time the action is fired. What might I be doing wrong?

Here is my code so far:

function add_locked_term( $strOldStatus, $strNewStatus, $post ) {
 if( $post['post_type'] !== 'property' )
     return;

        $term = 'locked';
        $tax = 'Status';
        wp_set_post_terms( $post, $term, tax); 
}
add_action( 'transition_post_status', 'add_locked_term' );

Can someone point me in the right direction?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.