Skip Navigation

[Resolved] Send author data to next page

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 11 replies, has 2 voices.

Last updated by avansisI-2 3 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#1964139

Hello

I have a page created through a post form. When a user fills out the form, the user creates the page. Thats okay.

Now I want to include a contact button that takes visitors to a single form.
In this form, the system will take the user's data from the previous page, and will send the form.

example:

When pressing the contact button, you would need the form to send the information to the email of the user who created the page (post author).

How do you think we can do this?

I think that using a single form for all users and maybe form can receive the email post author vía jquery or something like that.

Thank u

#1964583

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Avansis,

Thank you for getting in touch.

The way i'm thinking of doing this is to pass the ID of the current page into the page where you have your form.

To do this you will need to create your link like this below.

<a href='linktoformpage/?contact_id=[wpv-post-id]'>Click Me</a>

Now when the user clicks on the Click Me link they will be sent to the form page with a url parameter called contact_id that has the ID of the post they are coming from.

From there on your form you can retrieve any field value from the previously clicked post by setting the default value of your form fields to [types field="my-field" item="[wpv-search-term param='contact_id']"]

Where my-field is the slug of the field that I would like to get.

Please try this and let me know if it helps.

Thanks,
Shane

#1965445
Captura de pantalla 2021-02-24 a las 13.44.15.png
Captura de pantalla 2021-02-24 a las 13.42.05.png

Thank u Shane!

I get the URL: hidden link

I think that '/?contact_id=1346' it works because 1346 is the id of the origina page.

But now, i created a new form on the second page and contact id not appear on my frontend form, the value is empty. How i can add that data (author email for example) to email notification?
I tried but i dont know how it works. i attached you a screenshoot of the set up form.
It is okay?

Thank u

#1965601

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Avansis,

I'm assuming that the author email is stored on the Post in a custom field? or is it stored on the user who created the post?

From your screenshot I noticed that you are just using [wpv-post-id] to add a value to the field, however this won't work because the [wpv-post-id] will always get the current ID of the page that it is on and not the ID that is being passed in the URL.

To get the id in the URL you will need to use this shortcode.

[wpv-search-term param='contact_id']

To use this ID to get a custom field's value you will need to do this below.

[types field="my-field" item="[wpv-search-term param='contact_id']"]

Where my-field is the slug of the custom field.

If your author email is stored in a custom field then the method above will work to get that email.

Thanks,
Shane

#1965665

Author email is stored on the user who created the post.

#1966029

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi avansis,

Given that the information is stored on the author then we will need to use a custom shortcode in order to do this.

Here is a code that i've written to get the author's email.

// Add Shortcode
function cust_get_author_meta( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'post_id' => '',
		),
		$atts
	);

	$post = get_post($atts['post_id']);
	$author_email = the_author_meta('user_email',$post->post_author);
	return $author_email;

}
add_shortcode( 'cust_get_author_meta', 'cust_get_author_meta' );

Add this to the Toolset custom code section in Toolset -> Settings -> Custom Code and activate it.

The usage is like below.


[cust_get_author_meta post_id='[wpv-search-term param="contact_id"]']

Please try this and let me know if the author email shows up in the field.

Thanks,
Shane

#1966431
Captura de pantalla 2021-02-25 a las 10.27.15 copia.png

Okay. Now it's working perfect! But i attached how it shows and i cant move to another position of the page. Its possible to move below or apply a display none?

Now, i would adding the email to notification email when form is submit and publish a page with the info added.

i think that i know how to publish the info but i dont know how to add the author email to email notification

Can you help me?

Thank u Shane!

#1966937

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

1965445-Captura_de_pantalla_2021_02_24_a_las_13.42.05.png

Hi Avansis,

In order to send the email in the notification you need to add it to the form itself.

You will need to add my custom shortcode to the message to field as its value. See your screenshot.

This will pass the email into the form and then you can just retrieve this field in the email notification. I'm assuming that you want the email to be added to the Message To: field.

Thanks,
Shane

#1966959
Captura de pantalla 2021-02-25 a las 16.34.25.png
Captura de pantalla 2021-02-25 a las 16.35.10.png
Captura de pantalla 2021-02-25 a las 16.34.25.png

Hi Shane,

I put [wpv-post-id] into Message to: Field but when i refresh the page field is empty.

in addition, i dont know how put the email field into email notifications. I dont know which option is or where i have to put the shortcode.

Thank you

#1966991

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2021-02-25 at 10.55.36 AM.png

Hi Avansis,

The field value is the first option. See my screenshot . Where it says "set a default value for this field".

Now in this area you are going to add the custom shortcode i've created [cust_get_author_meta post_id='[wpv-search-term param="contact_id"]']

Once you've done this the email should show up in this field. If you are still having challenges you can provide me with admin access and I can set this up for you.

Thanks,
Shane

#1967287

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Avansis,

This should now work. I've remade the shortcode to get the ID directly from the url itself so you don't need to manually pass in the parameter.

function cust_get_author_meta( ) {
 
    
 	if(isset($_GET['contact_id'])){
     $post_id = $_GET['contact_id'];
    $post = get_post($post_id);
    $author_email = get_the_author_meta('user_email',$post->post_author);
     return $author_email;
    }
 
 
}
add_shortcode( 'cust_get_author_meta', 'cust_get_author_meta' );

Please try now and it should give the email in the field.

Thanks,
Shane

#1967913

My issue is resolved now. Thank you!