PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Post creation - Validate if title already exist before creating

  1. Hi everyone,

    I have a couple of Gravity Forms to populate some custom types (user generated content).

    For one of those custom type, users shouldn't be able to create a new "post" if one with the same title already exist. Instead, I would like to redirect them to the existing post.

    I'm a bit new with Wordpress so I'm not sure how I should do this.

    PS : I only need some hints, but if somebody is willing to help me with this and can spare an hour or two, I would be willing to pay.

    Edit : It's may be easier if I explain why I want to do this : Users (mostly adolescents) will type a job they would like to do. If it's not in the database, it will create a new post where they can discuss about it (comments) and/or do a "Facebook Like". If the job is already in the database (also going to use autocomplete), they will be redirected to the exising post to continue the discussion.

    Posted 14 years ago on Thursday August 12, 2010 | Permalink
  2. So hints first.

    • You'll need to use the gform_pre_submission hook to compare the submitted post title to all of the post titles currently active on your site.
    • If the same post title does exist, redirecting the user directly to that post without explanation might be a little confusing. It might be more ideal to handle this similar to how Gravity Forms currently handles errors; it returns users to the form with the incorrect fields highlighted. In your case, I would recommend just adding a notification at the top of the form that let's the user know a job with that post title already exists and provide a link for them to go view it.

    This might be a difficult undertaking if you're new to WordPress/Gravity Forms. I do provide freelance support for WordPress and Gravity Forms so if you're interested, please feel free to get in touch: david@ounceoftalent.com.

    Hope this helps! :)

    Posted 14 years ago on Thursday August 12, 2010 | Permalink
  3. Thanks David!

    I would be happy to work with you on this. I've just sent you an email.

    Posted 14 years ago on Thursday August 12, 2010 | Permalink