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 13 years ago on Wednesday June 1, 2011 |
Permalink