B
B
Ballfenya2018-08-07 15:22:59
Contacts
Ballfenya, 2018-08-07 15:22:59

How to send a variable from the same page in the contact form using Contact Form 7 and CF7 Dynamic Text Extension?

It is necessary that in the form created in the Contact Form 7 plugin and CF7 Dynamic Text Extension a variable from this code is sent. From the same page where the contact form is located.
Code:
<?php
$status_terms = get_the_terms( $post->ID, 'property-status' );
if ( ! empty( $status_terms ) ) {
$status_count = 0;
foreach ( $status_terms as $term ) {
if ( $status_count > 0 ) {
echo ', ';
}
echo esc_html( $term->name );
$status_count++;
}
} else {
echo ' ';
}
?>
It is necessary that this variable property-statuspassed in the form. In the subject of the letter or in the text itself.
Help me please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2018-08-07
@wtrouble

Write this variable to the data attribute somewhere on the page: data-property-status="<?php echo $status_terms; ?>"
in the form you will have a [dynamictext dynamicname id:status]
script to pass the value with data-property-status in field id status:
var name = $(class_name_on_which_data_attribute hangs).attr('data-property-status');
$('#status').val(name);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question