Support » Plugin: User Submitted Posts » Conflict between USP Plugin and form

  • Resolved junonedel


    Hi. Thank you in advance for this wonderfull plugin!

    I need some assistance about a page I’ve been developing with USP plugin. So the idea is to have a page section where the user would click a button and then get a random post from the site archive. This same page would also have another section with a form that allows the user to send posts to the archive (I’m using USP Plugin to make this happen).

    The first section and the PHP snippet to randomize posts seem to be working ok. The plugin also works perfectly. Problem is I cannot make these two sections work together. Every time I click on the button, instead of displaying random posts, I get redirected to the USP form on the bottom of the page and receive the warning “Please complete the required fields”.

    Now I’m definitely new to PHP, but it looks like my button is also triggering USP Plugin error message. Is there a way to keep both forms on the same page and avoid this unwanted interaction?

    I’m pasting my scripts below, in case it helps:

    //Button HTML
    <form method=”post”>
    <input type=”submit” name=”randomize” value=”randomize”/>

    //PHP Snippet to Randomize Posts On Button Click
    if($_SERVER[‘REQUEST_METHOD’] == “POST” and isset($_POST[‘randomize’])) {
    $the_query = new WP_Query( array ( ‘orderby’ => ‘rand’, ‘posts_per_page’ => ‘1’ ) );
    while ( $the_query->have_posts() ) : $the_query->the_post();
    the_tags ();
    wp_reset_postdata(); }

    Thank you very much,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeff Starr


    I’m not sure tbh, this falls way outside of plugin support. But I do want to help, so maybe look at the function usp_error_message() (line 1420 in user-submitted-posts.php). There you can apply a filter hook called usp_error_message. That will enable you to check the query and return empty if the POST is from the other form. Again, far outside the scope of provided support, but hopefully it gives you some ideas.

    Thread Starter junonedel


    Thank you very much for your attention and support. I’ll give it a try 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conflict between USP Plugin and form’ is closed to new replies.