mercredi 20 janvier 2016

wordpress: failed to hook wp_insert_term

I'm trying to create a meta for term, which contain the id of the author who create it, as I know I need to hook the function wp_insert_term() but I didn't got it

function author_as_meta($term) {
    $x = add_term_meta(get_term_by('name', $term, 'novel'), 'owner', get_current_user_id()); 

    if(!$x) {
        wp_die($x);
    }
}
$taxonomy = 'novel';
add_action('create_'.$taxonomy, 'author_as_meta');

"novel" is My custom taxonomy, I've tried category too but it's still not working, I also tried to use the variable $taxonomy which should contain the name of taxonomy but it returns an error "undefined"



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire