• I am having an issue where users are clicking “publish post” multiple times while button is loading and already clicked, creating duplicant posts.

    Id like to prevent this. But i don’t think disabling button after clicking would be wise because typically a user will try to click publish button without filling in all forms, resulting in a “required” message.. So if i can disable after form is actually successfully submitted, that would be more ideal.

    Here is my current code:

    <div class=”large-12 columns”>
    <?php wp_nonce_field(‘post_nonce’, ‘post_nonce_field’); ?>
    <input type=”hidden” name=”submitted” id=”submitted” value=”true” />
    <button class=”button expanded” type=”submit” name=”submit”><?php esc_html_e(“Publish Now”, ‘betube’) ?></button>
    </div><!–Publish Button–>

    Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hello, gorvie.

    If you wanted to, you could target and disable the submit button only on form submission using some jQuery (if you’re comfortable with that).

    According to the W3 schools site:

    The submit() method triggers the submit event, or attaches a function to run when a submit event occurs.
    The submit event occurs when a form is submitted. The submit() method triggers the submit event, or attaches a function to run when a submit event occurs.

    I’m guessing something along the lines of:

    $("exampleForm").submit(function(){
      $("button .button.expanded").attr("disabled", true);
    });

    where “exampleForm” represents the CSS selector for your form could work.

Viewing 1 replies (of 1 total)
  • The topic ‘Prevent Duplicant Post Submissions/ Double Clicks’ is closed to new replies.