Hello! I am not sure if I am following you. So you want to get the value of the email of the current user who is logged in and put that in a text box of a Ninja Form?
oops! I mislead you, what I mean.
How can I email the post author?
If the form is on a specific post, then you can use a hidden field in which you can use this hook to retrieve the post ID then use that to subsequently use the post author’s email. This will require you to do some coding.
I can’t understand. I’m sorry.
I just want to make it like this
<input type="text" value="email_of_the_author">
I wanted to know where is the default email located?
Let me explain how you can do that a little bit clearer. You can use a hidden field then use the hook I referenced to earlier in which you can then use this code to insert the email address into the field: <?php the_author_meta('user_email'); ?>
. Then you can use that hidden field as the email address to send form submissions to.
Ok, where can I find the file path?
to insert these codes.
Sorry, I’m not good in wordpress
I see. First, you will need to be working with a child theme. Please make a child theme using this guide then get back to me.
do you have skype? so we can chat. ahaha
sorry. I just need this for my project in school.
Well, per the Forum’s rules, we can’t do that as I can only offer you free support here.
Ok, I’m done with child theme. What’s next?
Yes, activate it. If there are no problems when it is activated, pProceed with my instructions below.
All right. Great. Now, create a file called function.php
file in the root of your child theme folder.
In that file, add this:
<?php
function my_filter_function( $data, $field_id ){
// $data will contain all of the field settings that have been saved for this field.
// Let's change the default value of the field if it has an ID of 3
if( $field_id == 3 ){
global $post;
$data['default_value'] = the_author_meta('user_email');
}
return $data;
}
add_filter( 'ninja_forms_field', 'my_filter_function', 10, 2 );
Of course, make sure the field id is correct.
Its working fine. Ok, I’m done adding codes to function.php
Good. Now, it is time to test it out. π
hahaha, really? that’s it?