How to get Form ID Programatically

This topic contains 5 reply and 2 voices, and was last updated by Tareq Hasan 10 years, 7 months ago
Viewing 5 Posts - 1 through 5 (of 5 total)
Author Posts
September 11, 2013 at 10:53 pm 8033
Tareq Hasan Hello I have a Guest Posting form in a custom page template and I call that form inside the template via php code: <?php echo do_shortcode("[wpuf_form id=\"37\"]"); ?> Thing is, this is multisite and people will create similar websites inside this multisite and they will have to create their own form. How can I include this form inside the template in a way that it automatically grabs the ID of the form inside that php snippet? Any solution ideas please? Thanks in advance! Cheers
September 12, 2013 at 5:58 am 8051
Tareq Hasan Tareq Hasan

I am not sure what are you asking. Can you elaborate more please?

September 12, 2013 at 8:25 pm 8085
RockNRolla RockNRolla

Hello.
Thanks for response.
Sorry if I wasnt clear.

Here is the scenario of my situation.

I have a custom page template in my theme, called page-submit.php

That is the template which renders the page where all the guests, non logged in and non registered users submit the posts (I have guest post enabled in WP Frontend User PRO plugin)

To display the Guest Post form in this page-submit.php form, I use wordpress do_shortcode function:

`

Form ID is 37.

Everything works just fine. But, when I add another wp site (its a Multisite installation), I will have to create the same guest post form there too, and the Form ID will NOT be the same right? so, my page-submit.php template in that blog will not work, as it calls out pwuf_form id=37, which will be true only for the first main site, all other sites will have guest post forms with different IDs.

I need to come up with the solution to somehow, display the guest post form in a way, that the form will display in all blogs, regardless of form ID or whatever.

Any opinions?

September 13, 2013 at 3:10 pm 8102
Tareq Hasan Tareq Hasan

With a single form, it’s not possible to manage the whole network.

Here’s what might be a workaround:
1. Create a master form.
2. As the form settings and form fields are stored in the custom field, collect those data and store in a PHP array.
3. Whenever a new site is created, run a function to create a form automatically and save the form id in a option for that site.
4. In your page template, get the current sites saved form id from the option and show the form.

September 13, 2013 at 11:04 pm 8115
RockNRolla RockNRolla

Thanks for response. Can you clarify couple things please

1) Create a Master form << Master form? You mean a form on a main website of Multisite? 3) <> How can I do that?

September 14, 2013 at 6:53 am 8130
Tareq Hasan Tareq Hasan

1) Just create a form anywhere and copy the custom field value.
3) Like that

Viewing 5 Posts - 1 through 5 (of 5 total)