Appending the page title and/or URL to a BB contact form submission

I was given some help with this in the Beaver Builder Facebook group with this:

$('.submitbutton').on('click',()=>{

$('.textarea').text = $('.textarea').text + document.title;

});

Not knowing JS, but seeing an error I changed it to this:

(function($) {
$('.fl-button').on('click',()=>{
$('.fl-message').text = $('.fl-message').text + document.title;
})(jQuery);

No joy, but wondering if it is possible?

This is easier in PHP … should have just asked me first :wink:

add_action( 'wp_ajax_nopriv_fl_builder_email', function() {
	$post_id = sanitize_text_field( $_POST['post_id'] );
	if ( $post_id ) {
		$title = get_the_title( $post_id );
		// inject title
		$_POST['message'] .= "\n\n" . 'Sent from: ' . $title;
	}
}, 9 );
1 Like

This is like magic to me. Brilliant, thank you so much once again.

If anyone else is using just note I needed to be logged out of WP for it to work.

If you add the same code tp wp_ajax_fl_builder_email action it’ll work logged in :slight_smile:

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.