I have a function hooked on created_term
and I'm trying to add a message a return success or error message. Categories are created with Ajax, I tried some things but it's overwritting Wordpress error and causing bugs.
My code so far:
add_action( 'created_term', 'push_term', 20, 3);
function push_term( $term_id, $tt_id, $taxonomy ) {
$contentarray = array();
$term = get_term_by( 'id', $term_id, $taxonomy);
if(!empty($term->name)){ $contentarray['category_name'] = $term->name; }
if(!empty($term->slug)){ $contentarray['category_slug'] = $term->slug; }
if(!empty($term->description)){ $contentarray['category_desc'] = $term->description; }
$category = $taxonomy.'_#'.$term_id;
if(post_content($apikey, $websitekey, $category, $contentarray)){
if ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX )
{
}
}else{
if ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX )
{
}
}
}
Thanks in advance, been trying to figure this out for a while...
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire