Save Meta when custom Taxonomy Saves

I am in need of some advice, we are setting up a custom tag for Movies. We want to have it pull from the OMDB Api when it is saved. We have the function setup, but it is not firing, and I am stumped.

I am trying to have this call when I save the custom taxonomy, so it populates the info needed for the details.

Is there is something I am missing, please let me know,

BugFu is reporting information correctly, but it stil is not saving the changes to the field. Currently, every part of the code seems to fire, with even the remote aspect working. It seems to be the part where it tries to write the change to the custom field.

The code is supposed to take the response from the remote OMDB, parse it, and save the different data sets into the custom fields. The Fields are not shared with any other custom terms.

thanks for all the help!

 function wpse_edited_term( $term_id, $tt_id, $taxonomy ) {
 
    // Do something.  
   $api_key = 'xxxxxx';
   $imdb = get_term_meta( $term_id, 'imdb_id', true );

  
  
$request = wp_remote_get( 'http://www.omdbapi.com/?apikey='.$api_key.'i='.$imdb );
  
  if( is_wp_error( $request ) ) {
    return false; // Bail early
}

$body = wp_remote_retrieve_body( $request );
$data = json_decode( $body );

$title = $data-Title;
$plot = $data-Plot;
$released = $data-Released;
$director = $data-Director;
//$genres = $data-Genre;
$runtime = $data-Runtime;
$actors = $data-Actors;
$country = $data-Country;
$language = $data-Language;
$poster = $data-Poster;

update_term_meta( $term_id,'movie_premiere_date', $released);  
update_term_meta( $term_id, 'movie_detail_directors', $director);
update_term_meta( $term_id, 'film_genre', $genres);
update_term_meta( $term_id, 'movie_running_time', $runtime); 
update_term_meta( $term_id, 'country', $country); 
update_term_meta( $term_id, 'language', $language);
update_term_meta( $term_id, 'product_image', $poster);   
update_term_meta( $term_id, 'cast', $actors);

BugFu::log($poster);
}  

add_action( 'edit_term', 'wpse_edited_term', 10, 3 ); ```

Topic code functions metabox Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.