PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

sending an email in an API hook/and can set the order of my hooks?

  1. pagedmedia
    Member

    I have seen questions for rerouting the notification email - but what I want to do is send a email that is not apart of the notification email - since I'm scripting an email from some of the information collected in the email to generate a paypal link for the user to use.

    It seems that the email is being sent - but while I receive the notification email, I'm not receiving the email sent through my hook script.

    Also - since I use one hook script to change some information for my form (via the http://forum.gravityhelp.com/topic/renaming-uploaded-files-before-saving - thanks!) - if I run another script pulling the entry information and dumping it into another database for use else where - my change doesn't follow - so could be hook scripts be running at the same time or is there a set order I can use.

    I know - I'm asking two questions here.

    Posted 13 years ago on Tuesday August 10, 2010 | Permalink
  2. I am not sure I follow 100%. It might be helpful if you include your code and a brief explanation of what you are trying to accomplish with each of the hooks.

    Posted 13 years ago on Tuesday August 10, 2010 | Permalink
  3. pagedmedia
    Member

    <script src='http://pastie.org/1084854.js'></script>

    The first one: rename_file - is from this forum - http://forum.gravityhelp.com/topic/renaming-uploaded-files-before-saving - where the file name is being changed to the entry number and the name of entry

    The second one: into_entry is where I'm taking the information that was collected by gravitt form and dumping it into a table in a separate data base - but the change in the rename_file script is not taking :( I probably don't have to assign a variable to each of the entry[#] values - I was just having problems having everything line up correctly. Thr purpose of this is that I will be doing querying with the information with another table in the database.

    The third one: email_pay - is there I am generating a paypal link with information from the gravity form, entering it into another table, and sending an email to the person with information about their payment selection (no paypal link if they selected check) There is also a preg_match search to the value of $membership to decide what the cost will be - if Houston exist in $membership cost is $20, else it is $30 - this information is used in the link. Link creation works - I just have a problem with the email not being sent (it says it sends but it must still be out there in internet land.)

    I would like for them to run in this order - in order to take advantage of name change on the file (because I will have to write another post script that sends that file ask an attachment to yet another email.) Complicated, I know. But if I can get hooks to accomplish all of this - less work for me in the long run.

    Thanks.

    Posted 13 years ago on Tuesday August 10, 2010 | Permalink
  4. pagedmedia
    Member

    oops.. here is the link to the code. http://www.pastie.org/1084854

    Posted 13 years ago on Wednesday August 11, 2010 | Permalink
  5. You will need to do 2 things:
    1- Make sure your functions are called in the right order. To do that, you will need to change the third parameter of the "add_action" function:

    add_action("gform_post_submission", "rename_file", 1, 2); //executed first
    add_action("gform_post_submission", "into_entry", 2, 2); //executed second
    add_action("gform_post_submission", "email_pay", 3, 2); //executed third

    2- You will need to re-get your entry from the database. The first function manually changed the entry in the database and that won't automatic reflect in the $entry parameter of the other functions. Use the following code snippet. You may need to do the same for the "email_pay" function.

    function into_entry($entry, $form){
        //refreshing $entry variable with new values from database
        $entry = RGFormsModel::get_lead($entry["id"]);
    
       /...... rest of your code ........../
    }
    Posted 13 years ago on Wednesday August 11, 2010 | Permalink
  6. pagedmedia
    Member

    DANKA! GRACIAS! DOMO! :)

    Posted 13 years ago on Wednesday August 11, 2010 | Permalink