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.

Insert a gravity form onto author's profile page

  1. Andrew Munro
    Member

    What I would like to do is insert a Gravity Form onto each individual author's profile page which would send them an email. Eg. http://www.sitename.com/authors/username

    Obviously I would want just 1 form for all authors, and have the form send the information to the author's email address. I know how to insert a form using <?php gravity_form(1); ?> where 1 is the form ID, but how do I get the form to automatically pick up the author's email address from their profile page? I'm guessing there is a way to dynamically populate the form with the author's email address but I'm not too good with php.

    If someone could point me in the right direction, I'll try my best :)

    Posted 12 years ago on Wednesday May 18, 2011 | Permalink
  2. I am currently looking to do this as well. I have submitted a request for this too, and no answer. If they respond to my post I will be sure to let you know what goes on!

    Posted 12 years ago on Wednesday June 1, 2011 | Permalink
  3. Okay turns out I figured it out about 15 mins after I posted here... This might not be the best solution, but it is working!

    I am assuming you have this on your author page:

    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));

    First, you need to create a hidden field in your form:

    - Edit your Form
    - Add a hidden field you want to populate and give it a name
    - Edit the hidden field
    - Select the Advanced tab
    - Select the "Allow field to be populated dynamically" checkbox
    - Give the field a parameter name, this parameter name is used to target the field so name it something simple like "email" or something similar.
    - Save your form

    Then you would use the gform_field_value hook by adding custom code in your themes functions.php file to dynamically populate that field. For example, if you set the parameter to "email" your code would look like this:

    in your functions.php file add this:

    // NO ID after value_email
    add_filter( 'gform_field_value_email', 'populate_email' );
    function populate_email(){
     global $curauth;
    	return $curauth->user_email;
    }

    and then again in your functions.php file add this:

    // update the '1' to the ID of your form
    add_filter("gform_notification_email_1", "change_notification_email", 10, 2);
    function change_notification_email($email, $form){
    
        // update the '5' to the ID of your field
        $email = $_POST['input_5'];
    
        return $email;
    }

    Remember to change your ID's to reflect your form.

    If you have any issues let me know! Enjoy!

    Posted 12 years ago on Wednesday June 1, 2011 | Permalink