Advertisement
verygoodplugins

Untitled

May 23rd, 2025 (edited)
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. // Apply tags after import.
  2. function add_past_webinars( $post_id, $xml_node, $is_update ) {
  3.     // Retrieve the import ID.
  4.     $import_id = wp_all_import_get_import_id();
  5.     // Only run for import 60.
  6.     if ( $import_id == '60' ) {
  7.         // Convert SimpleXml object to array for easier use.
  8.         $record = json_decode( json_encode( (array) $xml_node ), 1 );
  9.         // Do something.
  10.         if ( array_key_exists( 'webinars', $record ) && ! is_array( $record['webinars'] ) ) {
  11.             $tags     = array();
  12.             $webinars = explode( '^', $record['webinars'] );
  13.             foreach ( $webinars as $webinar ) {
  14.                 array_push( $tags, $webinar );
  15.             }
  16.  
  17.             if ( ! empty( $tags ) ) {
  18.  
  19.                 foreach ( $tags as $tag ) {
  20.                     if ( ! wpf_get_tag_id( $tag ) ) {
  21.                         wp_fusion()->crm->add_tag( $tag );
  22.                     }
  23.                 }
  24.  
  25.                 error_log( 'LG-error: post_id: ' . print_r( $post_id, true ) );
  26.                 error_log( 'LG-error: tags: ' . print_r( $tags, true ) );
  27.                 $apply = wp_fusion()->user->apply_tags( $tags, $post_id );
  28.                 error_log( 'LG-error: apply: ' . print_r( $apply, true ) );
  29.             }
  30.         }
  31.     }
  32. }
  33. add_action( 'pmxi_saved_post', 'add_past_webinars', 50, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement