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.

Problems with using Custom Field in Send To Notification

  1. Fika
    Member

    Hello,

    I am trying to populate the "Send to Email" field under the notification section with a custom field I have in a post with the form on it. I have unsuccessfully tried 2 different methods and both did not work.

    The error I get on the field when saving on both is "Please enter a valid email address"

    ** Method 1
    I first tried to add the merge code to the input field in notifications as so
    {custom_field:[name]} in my case this was {custom_field:[emailaddresses]}
    this gave the validation error that it was not an email address when saving

    ** Method 2
    I then tried adding a custom field to the form itself and set it to admin so it was hidden from users. I think tried passing that field value in to the notification to see if that would work but same issue. I used the following code
    {[Field Name]:[1]} wjere my field ID was '1'

    Would really appreciate help on this as I will have 300 posts all using the same form but have different email addresses in each that they need to get sent to.

    Thanks

    Posted 12 years ago on Wednesday June 20, 2012 | Permalink
  2. Fika
    Member

    bump! any chance of some support on this issue??

    Posted 12 years ago on Monday June 25, 2012 | Permalink
  3. David Peralty

    Can you post a link to your form?

    Posted 12 years ago on Monday June 25, 2012 | Permalink
  4. Fika
    Member

    Hi David,

    Unfortunately I am working on a localhost environment so I cannot post you a link.

    Should what I am trying to describe work?

    I can post screen shots of the error if that helps?

    Posted 12 years ago on Tuesday June 26, 2012 | Permalink
  5. Fika
    Member

    Hello,

    I am still waiting on some support on this issue I need fixed.

    Thanks

    Posted 12 years ago on Tuesday July 3, 2012 | Permalink
  6. David Peralty

    Can you put up some screenshots? Something that can help me understand better what is happening and what you are trying to do. You can't use admin only fields.

    Have you thought about trying to have a field, hidden by CSS that is an e-mail field, and then copying the value from your custom field to the e-mail field using the pre-submission hook and using that field for the to field in your e-mails?

    Posted 12 years ago on Tuesday July 3, 2012 | Permalink
  7. Fika
    Member

    Hi Dave,

    Let me try and explain it better for you, I may have been a bit fuzzy above.



    ** Posts **
    * I have roughly 300 posts on my site
    * each post has a custom field which displays the email address of the real estate agency. Custom field name is "emailaddresses"
    * each post uses a contact form for contacting the real estate *directly*



    ** Contact Form **
    * I have 1 contact form which is used in all posts above (form id 1)
    * My contact form is quite simple and consists of the regular contact information
    * I also have an additional email field which is set to Admin Only to hide it from the user on the front end. (intention with this field is to collect that email from custom field)



    ** Proposal **
    * I want to populate the additional email field which I have hidden (admin only) with the email address from the custom field on the post.
    * I will then insert a mergetag into the "Send to Email" field on the notifications page so that the email from the custom field is used when the user uses the form. For example I will use this merge tag {Email:4}
    * I am assuming this is the correct way to do such a thing?



    ** Questions **
    * I have looked into the documentation for query string, shortcode and hooks but I don't understand how to do it or what is best for my scenario.
    * I have also tried setting a parameter in the hidden field but as I don't understand the above point I am not sure how to get it all to work.

    Would really appreciate some help

    thanks

    Posted 12 years ago on Thursday July 5, 2012 | Permalink
  8. Fika
    Member

    Hi, did the latest explanation help?

    Posted 12 years ago on Sunday July 8, 2012 | Permalink
  9. Fika
    Member

    Hi Would really like to get some support on this issue?

    Posted 12 years ago on Tuesday July 10, 2012 | Permalink
  10. David Peralty

    * I want to populate the additional email field which I have hidden (admin only) with the email address from the custom field on the post.

    - You can't use an admin only field like this, as that data isn't as available as a normal field. You will want to have a hidden field. You can hide the field using CSS if you have to. Then you should be able to use the merge code for that field and have the data submitted populate into the notification messages.

    * I will then insert a mergetag into the "Send to Email" field on the notifications page so that the email from the custom field is used when the user uses the form. For example I will use this merge tag {Email:4}

    That is correct, the only issue is that you can't do this with an admin only field.

    Let me know if that helps.

    Posted 12 years ago on Tuesday July 10, 2012 | Permalink
  11. Fika
    Member

    Hi David,

    Nearly there :)

    OK, so here we go!


    * So I have created a Single Line Text Field in my form at the end.
    * I will hide this in CSS so the users don't see it
    * I want this field to capture the email address from my custom field called "emailaddresses"
    * I click on advanced tab and choose "Allow field to be populated dynamically"

    Now I am stuck

    * What do I add as a parameter? All I know is that my custom field with the email address on each post is called "emailaddresses" is that what I enter as the parameter?

    Maybe you can help me understand what to write in there exactly.

    Also to note: The custom field I am talking about is not in the gravity form. It is a custom field in the post which I enter the email address for each contact.

    Thanks a lot, looking forward to putting this to bed, I am sure I ma missing something small...

    Cheers

    Posted 12 years ago on Wednesday July 11, 2012 | Permalink
  12. Fika
    Member

    Hi David,

    I actually have a bit more info, I am nearly there I can feel it!!!

    I have looked at the documentation closer and have tried to update this using hooks as outlined here http://www.gravityhelp.com/documentation/index.php?title=Using_Dynamic_Population&oldid=933

    The code I am using is as follows (Note my parameter name for the field I want populated is called "directemail")

    /* Gravity Forms Direct Contact Form */
    add_filter('gform_field_value_directemail', 'populate_post_author_email');
    function populate_post_author_email($value){
        global $post;
    
        $author_email = get_post_meta('emailaddresses', true); 
    
        return $author_email;
    }

    Now this does NOT work, but as soon as I add a POST ID to the get_post_meta it works. My test post is 19 so I add it as follows

    /* Gravity Forms Direct Contact Form */
    add_filter('gform_field_value_directemail', 'populate_post_author_email');
    function populate_post_author_email($value){
        global $post;
    
        $author_email = get_post_meta(19, 'emailaddresses', true); 
    
        return $author_email;
    }

    This works and populates the fields with the custom field 'emailaddresses' value. However the problem is that I don't want to enter the post ID as I need it to read the key value for the post it is on.

    Can you let me know how I can adjust the code to allow me to get the value from the post it is on?

    Thanks

    Posted 12 years ago on Wednesday July 11, 2012 | Permalink
  13. Fika
    Member

    got it

    $author_email = get_post_meta($post->ID, 'emailaddresses', true);

    Had to use $post->ID as the post ID

    Thanks for your help...

    Posted 12 years ago on Wednesday July 11, 2012 | Permalink

This topic has been resolved and has been closed to new replies.