This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Can custom_hooks.php use a variable for an email address?


  1. frankzobitz
    Member

    I would like to use one "contact us" form throughout an entire website and sub-sites. Through the use of variables, I know what site or sub-site the user is at when they initiate the "contact us" action.

    I was able to get the custom_hooks (http://www.appnitro.com/doc-dynamic-email) working by hardcoding the email addresses in it. However, I haven't been successful at passing it the email address through a variable. I do not want the user to have to choose who to send it to.

    This is what I have:

    global $mf_hook_emails;
    $mf_hook_emails[19734]['element_id'] = 7;
    $mf_hook_emails[19734]['Dept Notify'] = $deptemail;

    If I remove $deptemail and put in 'customer_service@abc.com' it works. If I echo the variable prior to the form being displayed on the page, the correct email address is displayed. Any idea how I can get the variable working properly in the statement?

    Posted 10 years ago #
  2. frankzobitz
    Member

    I have looked into this more and this is what I have discovered:

    If I put this directly into the custom-hooks file, it works as intended:

    global $mf_hook_emails;
    $deptemail= 'customer_service@abc.com';
    $mf_hook_emails[19734]['element_id'] = 7;
    $mf_hook_emails[19734]['Dept Notify'] = $deptemail;

    However, in my case, $deptemail is assigned when the page is built and the variable isn't making it to the custom-hooks file. I use the javascript code.

    Any help would be appreciated.

    Posted 10 years ago #
  3. yuniar

    I suggest to update to v3.5 and use the new conditional logic to send the email.
    You can add an email field into your form and populate the value of this field by using URL parameters.

    Then set the conditional logic to send the email using that email field as the destination address.
    Also, set the email field to be hidden by adding "hidden" keyword into the Custom CSS Class property of that field.


    MachForm Founder

    Posted 10 years ago #
  4. frankzobitz
    Member

    I upgraded to 3.5 and it works perfectly now using the new conditional logic feature. Thank you for a great piece of software!

    Posted 10 years ago #
  5. yuniar

    cool :-)


    MachForm Founder

    Posted 10 years ago #

RSS feed for this topic

Reply