I am adding (insert) into a non-Wp table soon after a specific post meta is updated this part works fine but when on the same function I try to update an another meta of the same post with the inserted ID of non-wp table. Post meta does not update.
I tried update_post_meta
custom update Query using wp_query
I am attaching my code below, please help me.
add_action( 'updated_post_meta', 'user_vid_update', 10, 4 );
function user_vid_update($meta_id, $object_id, $meta_key, $_meta_value) {
if (strpos($meta_key,'video_code') !==false){
global $wpdb;
$half_key=strchr($meta_key,"video_code",true);
$title=$half_key.'video_title';
$vid_key=$half_key.'vmdbid';
$result = $wpdb->insert( $wpdb->vimeography_gallery, array( 'title' => $vid_key, 'date_created' => current_time('mysql'), 'is_active' => 1 ) );
$s_url='https://vimeo.com/album/'.$_meta_value;
$r_url='/album/'.$_meta_value;
$gallery_id = $wpdb->insert_id;
$allery_id=$gallery_id;
$result = $wpdb->insert( $wpdb->vimeography_gallery_meta, array(
'gallery_id' => $gallery_id,
'source_url' => $s_url,
'resource_uri' => $r_url,
'featured_video' => NULL,
'gallery_width' => NULL,
'video_limit' => 25,
'cache_timeout' => 3600,
'theme_name' => 'bugsauce' ) );
update_post_meta($object_id, $vid_key,$allery_id);
}
return true;
}
When I echo "update_post_meta($object_id, $vid_key,$allery_id);";
I get values from all the variable and if i run this seperately post meta updates.
I am using Advance custom filed repeater to create fields that's why i am creating meta key's dynamic.
Thanks in advance