Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Apply tags after import.
- function add_past_webinars( $post_id, $xml_node, $is_update ) {
- // Retrieve the import ID.
- $import_id = wp_all_import_get_import_id();
- // Only run for import 60.
- if ( $import_id == '60' ) {
- // Convert SimpleXml object to array for easier use.
- $record = json_decode( json_encode( (array) $xml_node ), 1 );
- // Do something.
- if ( array_key_exists( 'webinars', $record ) && ! is_array( $record['webinars'] ) ) {
- $tags = array();
- $webinars = explode( '^', $record['webinars'] );
- foreach ( $webinars as $webinar ) {
- array_push( $tags, $webinar );
- }
- if ( ! empty( $tags ) ) {
- foreach ( $tags as $tag ) {
- if ( ! wpf_get_tag_id( $tag ) ) {
- wp_fusion()->crm->add_tag( $tag );
- }
- }
- error_log( 'LG-error: post_id: ' . print_r( $post_id, true ) );
- error_log( 'LG-error: tags: ' . print_r( $tags, true ) );
- $apply = wp_fusion()->user->apply_tags( $tags, $post_id );
- error_log( 'LG-error: apply: ' . print_r( $apply, true ) );
- }
- }
- }
- }
- add_action( 'pmxi_saved_post', 'add_past_webinars', 50, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement