Create a new form from php

Home Forums Quform WordPress Create a new form from php

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #25933
    pczjrh
    Participant

    Hi,
    I’m writing a plugin that depends on Quform for personal use.
    Is it possible to create a form (setting ID etc) and generate fields entirely in php?
    If so, are there examples anywhere?
    Many thanks,
    Jason.

    #25943
    pczjrh
    Participant

    OK, so I found out how to duplicate a form via the export function – that code can be c’n’p into another site, or page etc.
    When that form gets duplicated elsewhere it will get a unique form_id…

    why does this approach not work?

    
    //dynamically find the form id by searchng for the name
    $forms_array = iphorm_get_all_forms();
    foreach($forms_array as $f) {
    	if ( $f['name'] == 'Form Name Here' ) {
    		$post_process = "'iphorm_post_process_".$f['id']."'";
    	}
    }
    add_action( $post_process, 'my_post_process_1');
    
    #25947
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #25964
    pczjrh
    Participant

    Thanks Ally, very helpful.

    To follow up.. once I’ve got the form id and defined the action hook, I’ve defined a series of constants to construct the string used in the $form->getValues() call, as such

    
    define("id1", "'iphorm_".$f['id']."_1'");
    

    then using this within a callback function elsewhere

    
    $var = $form->getValue(id1);
    

    This results is an empty value for $var…
    Can you point me the right way to get the form fields dynamically?

    Thanks in advance,
    Jason.

    #25965
    pczjrh
    Participant

    Doh!

    define("id1", 'iphorm_'.$f['id'].'_1');
    

    is what is needed. I thought the call required an explicit string, but apparently not.

    I’ll leave the reply above for others to see if it’s helpful.

    Many thanks again for your help.
    Jason.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2025 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy