• Resolved kemalkautsar

    (@kemalkautsar)


    Hi,

    I have this custom plugin that I made, so this plugin will “add” a form whenever the plugin is activated. here’s the code sample:

    function add_theme_color_form()
    
    {
    
    ? if (!get_option('initial_terms_added_tcolor')) {
    
    ? ? // first run; ? ?
    
    ? ? $wrappers = array(
    
    ? ? ? array(
    
    ? ? ? ? 'wrapper_id' => 'wrapper-2630-6454',
    
    ? ? ? ? 'fields' ? ? => array(
    
    ? ? ? ? ? array(
    
    ? ? ? ? ? ? 'element_id' ? ? ? ? ? ?=> 'text-1',
    
    ? ? ? ? ? ? 'type' ? ? ? ? ? ? ? ? ? ?=> 'name',
    
    ? ? ? ? ? ? 'cols' ? ? ? ? ? ? ? ? ? ?=> '12',
    
    ? ? ? ? ? ? "field_label" ? ? ? ? ? ?=> __("Theme Colour", 'forminator'),
    
    ? ? ? ? ? ? "placeholder" ? ? ? ? ? ?=> __("E.g. text placeholder", 'forminator'),
    
    ? ? ? ? ? ? 'custom-class' ? ? ? ? ? => 'colorpicker',
    
    ? ? ? ? ? )
    
    ? ? ? ? )
    
    ? ? ? )
    
    ? ? );
    
    ? ? $settings = array(
    
    ? ? ? "formName" ? ? ? ? ? ? ? ? ? ?=> 'Theme Color Selector',
    
    ? ? ? "thankyou" ? ? ? ? ? ? ? ? ? ?=> "true",
    
    ? ? ? "thankyou-message" ? ? ? ? ? ?=> __("Setting saved", 'forminator'),
    
    ? ? ? "use-custom-submit" ? ? ? ? ? => "true",
    
    ? ? ? "custom-submit-text" ? ? ? ? ?=> __("Apply Selection", 'forminator'),
    
    ? ? ? "use-custom-invalid-form" ? ? => "true",
    
    ? ? ? "custom-invalid-form-message" => __("Error: Your form is not valid, please fix the errors!", 'forminator')
    
    ? ? );
    
    ? ? $notifications = array();
    
    ? ? Forminator_API::add_form(
    
    ? ? ? 'Theme Color Selector',
    
    ? ? ? $wrappers,
    
    ? ? ? $settings,
    
    ? ? ? $notifications
    
    ? ? );
    
    ? ? add_option('initial_terms_added_tcolor', 1);
    
    ? }
    
    }

    the problem that I’m having is that sometimes the form is set as published, sometimes its still set as draft. What i need and expect is it’s set as Published 100% everytime. Is there a way to always set the form as Published?

    I know there’s a line to set on the json export to set it as published but how do you do it programatically using the code sample above?

    thanks again!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter kemalkautsar

    (@kemalkautsar)

    Addition:

    I also don’t need the email notification under “Email Notifications”. as you can see I have set it to blank under $notifications but its still appearing. Can you point me out how to do it? thanks

    Plugin Support Laura – WPMU DEV Support

    (@wpmudevsupport3)

    Hi @kemalkautsar,

    Hope this message finds you well.

    I shared your code and requested our developers to check if they can provide some code since they work on complex issues getting a reply from them could take more time than usual, we will back to you once we get an update.

    Best regards,
    Laura

    Plugin Support Laura – WPMU DEV Support

    (@wpmudevsupport3)

    Hi @kemalkautsar,

    We got feedback from our developers and they update your code:

    function add_theme_color_form(){
        if (!get_option('initial_terms_added_tcolor')) {
          // first run;    
          $wrappers = array(
            array(
              'wrapper_id' => 'wrapper-2630-6454',
              'fields'     => array(
                array(
                  'element_id'            => 'text-1',
                  'type'                    => 'name',
                  'cols'                    => '12',
                  "field_label"            => __("Theme Colour", 'forminator'),
                  "placeholder"            => __("E.g. text placeholder", 'forminator'),
                  'custom-class'           => 'colorpicker',
                )
              )
            )
          );
      
          $settings = array(
            "formName"                    => 'Theme Color Selector',
            "thankyou"                    => "true",
            "thankyou-message"            => __("Setting saved", 'forminator'),
            "use-custom-submit"           => "true",
            "custom-submit-text"          => __("Apply Selection", 'forminator'),
            "use-custom-invalid-form"     => "true",
            "custom-invalid-form-message" => __("Error: Your form is not valid, please fix the errors!", 'forminator')
          );
      
          $notifications = array();
          $form_id = Forminator_API::add_form(
            'Theme Color Selector',
            $wrappers,
            $settings,
            'publish'
          );
          Forminator_API::update_form(
            $form_id,
            $wrappers,
            $settings,
            'publish',
            $notifications
          );
      
          add_option('initial_terms_added_tcolor', 1);
        }
      }

    Let us know the results.

    Best regards,
    Laura

    Thread Starter kemalkautsar

    (@kemalkautsar)

    Hi,

    Yes that seems to work, however I ran into another problem.

    The submit button doesnt appear (https://drive.google.com/file/d/1oK7KTncotURhS3B-8p0gIW6ruQD0D5BT/view?usp=sharing) even though both of our code has the Submit buttons

    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hello @kemalkautsar,

    Please take our apologies for the delayed reply. It appears we didn’t get a notification for some reason.

    I could not replicate this with the original snippet. If you still need help with getting the Submit button to show, please send us the current PHP code you are using.

    Please also provide the exported form, in order for our techs to review it on our end. Upload the exported file to Google Drive, Dropbox, or a similar cloud service, and share the link.

    Looking forward to your reply!

    Best Regards,
    Dmytro

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @kemalkautsar

    We didn’t hear back from you for quite some time so I’m marking this as resolved for now.

    If you have any follow-up questions, let us know and we’ll be happy to get back to you.

    Best regards,
    Adam

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.