Home Forums Plugin Support WP User Frontend Pro How to get Form ID Programatically

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  Tareq Hasan 5 years, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8033

    RockNRolla
    Participant
    Post count: 14

    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

    #8051

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #8085

    RockNRolla
    Participant
    Post count: 14

    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:

    `< ?php echo do_shortcode("[wpuf_form id=\"37\"]"); ?>

    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?

    #8102

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #8115

    RockNRolla
    Participant
    Post count: 14

    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?

    #8130

    Tareq Hasan
    Keymaster
    Post count: 2831

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

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘How to get Form ID Programatically’ is closed to new replies.