The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Attachment URL from ID
Hi, I have been able to add form entries into another database table using the relevant hook. It looks like this:
add_action('frm_after_create_entry', 'copy_data', 20, 2);
function copy_data($entry_id, $form_id){
if($form_id == 6){ //form id
global $wpdb;
$values = array('image' => $_POST['item_meta'][76], 'sku' => $_POST['item_meta'][67], 'material' => $_POST['item_meta'][68], 'size' => $_POST['item_meta'][70], 'shape_multi_select' => $_POST['item_meta'][69], 'stone_carat_weight' => $_POST['item_meta'][72], 'price' => $_POST['item_meta'][80], 'pair' => $_POST['item_meta'][82], 'is_a_set' => $_POST['item_meta'][81], 'set_how_many' => $_POST['item_meta'][90]);
$wpdb->insert('my_db_table', $values);
}
}
The trouble is, it is inserting the attachment ID and not the URL. I have seen this page, but I am unsure how to insert this into the function to return the URL.
Any suggestions greatly appreciated!
November 5, 2018 at 4:46 am
All you should have to do is wrap the image id in the function like this:
'image' => wp_get_attachment_url( $_POST['item_meta'][76] )
November 5, 2018 at 5:08 am
Thanks very much vfontjr, that worked a treat!
Discussion closed.