Skip Navigation

[Resolved] View list with checkbox for select rows and update selected rows submit

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user was getting the error
Call to undefined function dd_action() on their custom snippet.

Solution:

In this case it was a Typo. The user add dd_action instead of add_action()

Changing it to the correct function call resolved the issue.

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by mikeB-14 5 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#1347457

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);
}
}
}
}
#1347643

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mike,

Thank you for getting in touch.

I checked on this for you, however based on the error about dd_action(), it doesn't seem to be generated by this function.

The dd_action() function seems to be generated somewhere else.

Could you paste the entire error so that I can have a look ?

Thanks,
Shane

#1347763
error.JPG

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);
            }
        }
    }
}

       

Thanks
Tony

#1348297

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tony,

Try renaming your snippet to something else.

It seems the name of the snippet could be throwing the error because i'm not seeing any use of a function called dd_action in the code itself.

Thanks,
Shane

#1348743

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);

Thank you!