Home > other >  How to make a form disappear after submit in Wordpress plugin
How to make a form disappear after submit in Wordpress plugin

Time:11-03

I am building a WordPress plugin for my livechat. When someone downloads the plugin, I want them to fill out some information (name, e-mail, etc). After submitting that info, the form has to disappear/hide. For some reason I am not successful and imo I've tried everything. At the moment I'm trying to do it with an if-statement checking if the submit-button isset(). Unfortunately that didn't work.

Can someone please help me? The code for display the form and the page after submitting:

<?php 

public function display_plugin_setup_page()
    {

        if (isset($_POST['submitForm'])) {

            ?>

            <form action="options.php" method="post">
                <?php
                settings_fields('mister_chat_options');
                do_settings_sections($this->plugin_name); ?>
                <input name="submit"  type="submit" value="<?php esc_attr_e('Save'); ?>" />
            </form>

            <?php
        
        } else {
            // create the form

            ?>

            <form method="post" action="sendmail.php">

                <input type="hidden" name="formSent">
                <fieldset>
                    <input placeholder="Voornaam" type="text" id="vnaam" name="vnaam">
                </fieldset>

                <fieldset>
                    <input placeholder="Achternaam" type="text" id="anaam" name="anaam">
                </fieldset>

                <fieldset>
                    <input placeholder="Bedrijfsnaam" type="text" id="bnaam" name="bnaam">
                </fieldset>

                <fieldset>
                    <input placeholder="E-mailadres" type="email" id="email" name="email">
                </fieldset>

                <fieldset>
                    <input placeholder="Telefoonnummer" type="tel" id="telef" name="telef">
                </fieldset>

                <fieldset>
                    <input type="submit" name="submitForm" id="contact-submit" data-submit="...Verzenden">
                </fieldset>
            </form>
        <?php

        }

    }

CodePudding user response:

I placed the sendmail.php file inside the file above and that fixed my problem.

  • Related