0

I'm using cforms plugin, which provides a way for writing custom functions for the form action handler page, using the file my-functions.php and the function my_cforms_logic(.

The issue is that whenever I submit the form, the function works well but it runs for 5 times.

For example, if i write a statement in the function such as, echo "A"; then in the output I see, "AAAAA".

2

When it runs, check the $setting argument thats passed to the function.

my_cforms_logic gets called on several different hooks, some of which run almost simultaneously.

###
### Your custom application logic features
###
### "successMessage"    $cformsdata = cforms datablock
### "redirection"       $cformsdata = cforms datablock
### "filename"          $cformsdata = $_REQUEST
### "adminTO"           $cformsdata = cforms datablock
### "nextForm"          $cformsdata = cforms datablock
###
### "adminEmailTXT"     $cformsdata = cforms datablock
### "adminEmailHTML"    $cformsdata = cforms datablock
### "autoConfTXT"       $cformsdata = cforms datablock
### "autoConfHTML"      $cformsdata = cforms datablock
###

If you only want to run your custom function at one of these hooks, say "successMessage", then start your function off like this:

function my_cforms_logic($cformsdata,$oldvalue,$setting) {

    if ('successMessage' != $setting) return $oldvalue;

        // now, do your custom logic
        // [. . . ]

}

Its interesting, I was just figuring that out the other day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.