Hi
Beda helped me out with this about 2 months , i was just doing the last bit , but get this error
I am getting a
Call to undefined function dd_action() on my mod of the code
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
dd_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==42932)//Change to the Form ID you use here (it's 42847)
{
//get data to update with - you will need to change this to your custom field or fields, if you have many.
$data_to_update_with = $_POST['wpcf-email-request'];
//get data from post_ids parameters in URL - no change should ne needed here unless the attribute changes (it is post_ids here)
$url_params = $_POST['post_ids'];
//remove & - we need this to later easily create an array of all post_ids passed
//note, it would be wise to check here if you actually HAVE some post_ids or not, but this is a refinement to be done later
$url_params = str_replace('&', '',$url_params);
//split into array - the post_ids are many, so we need to ahve them each on it's own
$url_params = explode('post_ids=',$url_params);
//At this point we have an array of Post ID's we want to edit, as passed in post_ids url arguments, in an array
//now we can update all the posts in that array!
foreach ($url_params as $post => $id) {
//update only if Post ID is not 0
if ($id != 0){
//update the field you need to update, in this case a single line Types field, with the data you got from the Form, see first lines of the code above
update_post_meta($id, 'wpcf-email-request', $data_to_update_with);
}
}
}
}
I have added this in the custom code of toolset
I will add a screenshot of where the error occurs.
But i have pasted the whole script as before.
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
dd_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==42932)//Change to the Form ID you use here (it's 42847)
{
//get data to update with - you will need to change this to your custom field or fields, if you have many.
$data_to_update_with = $_POST['wpcf-email-request'];
//get data from post_ids parameters in URL - no change should ne needed here unless the attribute changes (it is post_ids here)
$url_params = $_POST['post_ids'];
//remove & - we need this to later easily create an array of all post_ids passed
//note, it would be wise to check here if you actually HAVE some post_ids or not, but this is a refinement to be done later
$url_params = str_replace('&', '',$url_params);
//split into array - the post_ids are many, so we need to ahve them each on it's own
$url_params = explode('post_ids=',$url_params);
//At this point we have an array of Post ID's we want to edit, as passed in post_ids url arguments, in an array
//now we can update all the posts in that array!
foreach ($url_params as $post => $id) {
//update only if Post ID is not 0
if ($id != 0){
//update the field you need to update, in this case a single line Types field, with the data you got from the Form, see first lines of the code above
update_post_meta($id, 'wpcf-email-request', $data_to_update_with);
}
}
}
}
My issue is resolved now.
Silly me
Typo in the code
I had
dd_action('cred_save_data', 'my_save_data_action',10,2);
should be
add_action('cred_save_data', 'my_save_data_action',10,2);