Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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".

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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