• Resolved ksequen

    (@ksequen)


    Hi,

    I used to pass some values and add them to the admin email, using my_cforms_logic.
    Since it is now deprecated, what should I use?

    For example, I passed a var like this:
    https://aquatec-ecosys.com/contactenos/solicitar-cotizacion/?ref=Producto:%20Bombas%20para%20desechos%20s%C3%B3lidos

    And used this function:

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

    ### example: the below code changes a user-variable in both the Text & HTML part of
    ### the admin email & auto confirmation email

    if ( $setting == “adminEmailTXT” || $setting == “adminEmailHTML” || $setting == “autoConfTXT” || $setting == “autoConfHTML” ||
    $setting == “adminEmailDataTXT” || $setting == “adminEmailDataHTML”){

    $post_reference = $_POST[“ref”];
    $post_subject = $_POST[“asunto”];

    if ($post_reference):
    $cformsdata[‘data’][‘ref’]==$post_reference;
    else:
    $cformsdata[‘data’][‘ref’]==”N/A”;
    endif;

    if ($post_subject):
    $cformsdata[‘data’][‘asunto’]==$post_asunto;
    endif;

    endif;
    return $oldvalue;
    }

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author bgermann

    (@bgermann)

    Did that code really run? It has a syntax error. The last “endif;” must be replaced by “}”.

    As far as I can see the code has no effect. Changing the three $cformsdata[‘data’][‘...’]==...; lines to assignments instead of comparisons would make sense.

    Even if the code runs as intended, you do not use the API call as intended. You just abuse it to change $cformsdata instead of $oldvalue, which you never touch.

    You should just use an arbitrary constant string in the admin email and replace it with a filtered value from $_POST via the cforms2_admin_email_filter.

    Thread Starter ksequen

    (@ksequen)

    OK, the thing is I don’t understand how to use the cforms2_admin_email_filter. Where should I use it? in the functions.php file? is there any documentation on how to use this?

    Can you give me an example of passing the parameter and including the info in the admin email?

    Plugin Author bgermann

    (@bgermann)

    Just look at its call in lib_validate.php and you see the passed variables. Please read through general WordPress docs on how to use WordPress filters.
    You should use a filter in an own plugin. A hacky solution would be writing it in your theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Passing Values’ is closed to new replies.