The thing is I have a WordPress page with a number of trips, and each trip has inserted a specific contact form (because it varies depending on dates, accommodations, etc.). The plugin used is “Contact Form 7”.
Now we want to give the option to book directly, which also involves providing details of the travelers (age, date of birth, etc.). I mean, through a button in the contact form, he would be directed to another page only with the form and with the same options as the first one but also adding the boxes to enter information for each traveler.
The first objective is not having to duplicate all the forms with the “booking version”, which is something I have achieved through the “Contact Form 7 Conditional Fields” plugin; all the information about the number of travelers is already included in the original contact form, but not shown if one of the fields is not filled with the text “Book the tour”. Then when you click on “I want to book the trip” it sends you to another page with the same form but which this text included, so It unhide the rest of the fields, using url parameters:
Trip-booking/?Header=Book%20the%trip
Now comes the second problem that I know not how to solve. The only content in the “book page” is a simple shortcode text, like this:
[Contact-form-7 id = “001” title = “Journey 1”]
So I have to make a page for each form, which is irritated.
My question is if there’s any way to “rewrite” the content dynamically via parameters url, so that if I put in the link this:
Trip-booking/?Header=Book%20the%trip?form=001
The page would have this code:
[Contact-form-7 id = “001”]
And if I type this another url for example:
Trip-booking/?Header=Book%20the%trip?form=002
The page would have this code:
[Contact-form-7 id = “002”]
So I have no idea of how to formalize it to avoid creating a specific page for each shortcode.
Obviously I’m open to any suggestions.
You can grab the formID from the URL and call do_shortcode.
$formId = $_GET['form'];
do_shortcode('[Contact-form-7 id="'.$formId.'"]');
https://developer.wordpress.org/reference/functions/do_shortcode/
Related
I have searched the web for answer for almost a day and I couldn't find any answer about that.
Assuming that I'm having a Form created by the simple elementor form widget, and a client inserting a data there(name, email, number) and in another page I have some icon buttons(email, whatsapp, etc..) that should redirect the client to contact me
Like this one:
https://wa.me/1XXXXXXXXXX (Whatsapp start a chat link)
What I want to accomplish is that the input value from "Phone field" will replace the "1XXXXXXX" in the URL after the form is submitted
Is there any way to accomplish that? or any guide?
You can use POST method of php.
All you have to do is to create a page (i.e. submit) and then create a file in your theme folder (rather use child theme) with the name page-submit.php and write down your php code in it (use cpanel/direct admin to edit the file). Also, you should send your form to submit page, use action attribute in your form tag.
I wrote a custom post type to centrally manage lead forms, this has an accompanying short code so a lead form can be added to a page using [lead-form id="574"] - in this example, 574 is the Id of the lead form. When this is added to a page, I use a specific template for landing pages that include lead forms.
There are the fields in the custom post type that I need to access in the template, but in order to access them, I need the Id of the lead form first. I have included some screenshots that I hope will clarify this a little better.
Lead forms are centrally managed in a custom post type, in this example, 574 is the Id of the custom post
The code for the shordcode grabs the id using while( have_rows('pages', $atts['id']) ): the_row(); The fields used for the custom post type are a repeater of pages, which has a repeater of questions which has a repeater of predefined choices. These fields are created using the Advanced Custom Fields plugin. The shortcode is basically looping through pages/questions/answers and building a string that the shortcode returns. When adding a short code to a page, I specify a template in the "Page Attributes" section so I can include some styles and javascript.
template-lead-form.php is the file used for the "LP Lead Form" The string that is built in the shortcode is outputted in the_content(), however, there are two fields that I need access to that I can only get by passing in the Id to the lead form.
I'd search for your shortcode in post_content and get id from there. Regex isn't my strong side, but probably something like this:
preg_match('/\[load-form [^\]]*id="([0-9]*)"\]/', $post->post_content, $res);
After that you'd have id in $res[1].
i am building a wordpress website for a client. i need to build 1 template type of page with a list of fields that the client can fill in to populate the page. so lets say i build a template page called Person Template. On it i have an empty picture placeholder on the left and an empty Name Field below that. On the right i have an empty "persons phone number" and "Persons email" field.
what i need to create somehow is a system that the client can enter these 4 items into wp-admin somewhere and save that as a new Person. Then they can repeat and save another Person until they have created say 100 Person pages.
How do I do this? I tried building a Custom Post Type called Person CPT. I have built a Page called Person Template. I have built some "Person CPT" posts and put them on a page but i dont know how to create the Entry Fields page for my client to use.
You're correct that you'll need to use a custom post type. To add the fields you have two options:
Add the fields using add_meta_box(). You'll then need to save this data as post meta. Then in your single-person.php template you would retrieve the meta using get_post_meta(). It's a tad cumbersome, as you need to write the markup for the meta box, hook it into an action to add it to the admin page, and verify the content before it's saved. Here's an article that walks you through it
Alternatively get yourself the Advanced Custom Fields plugin: it makes adding additional fields very quick and easy. I use it all the time.
Here's my scenario: I have a drupal 7 site. It's categorized by a taxonomy. Each taxonomy term is panelized to display its main page. For each of those pages, I want to add a webform that would allow the visitor to email the person responsible for that area. The responsible person is defined in a hidden field on the taxonomy term.
If I add custom content to the panelizer page with the token
%taxonomy_term:field-generic-email-address
the email address is displayed. However, I need to get that into the webform, and I can't get it to pull the value from the token - it just displays that exact text (I'm trying to add it to a hidden field, but I'm sticking it into the body just to see, and in either place, it shows the token text instead of replacing it with the email). Does anyone know how to do this?
You might want to check out a module called EntityForm https://drupal.org/project/entityform
It allows you to use regular Drupal fields to build a user-submittable form.
There are other ways to do this, but this method may allow you to get what you want and more.
So Magic Fields 2 doesn't have "write panels." and since MF2 is so sleek - I am thinking there is some other thing that takes it's place that I can't find.
problem is this: creating a simple page with some fields in it.
in MF1//
create some m-Fields
create a page
fill out the fields on the page
select the fields that i want as a write panel.
echo them out on the page
STRUCTURE: page>fields
in MF2//
create a page template
create a page
assign the template to the page
create a custom post type
create the fields for that post type
create a post
fill in all the fields
run a loop in the page for the post type (for 1 post)
echo out the m-Fields data
STRUCTURE: page>post>fields
so a client would have to select the post type "about" then go in there and get(the only post in there) "about" then adjust the fields... meanwhile the page "about" is never touched... seems really strange...
or --- you could put ALL of the magic-fields on "page" - which in my case would mean that there would be 100 plus fields on every page and 90 of them wouldn't have to do with that page and then couldn't be required --- which is all way too confusing for clients.
I feel like I'm just not checking a special box somewhere.
The answer is just NO.
I have since started using Advance Custom Fields plugin and you just set up your custom field sets and tell them what page or post type to appear on. I have more confidence that ACF will stay up to date then the other plug in options. Just wanted to throw that out there.