WordPress.org

Forums

Advanced Custom Fields: Validated Field
[resolved] Unique Field works only on Published content (5 posts)

  1. ikivanov
    Member
    Posted 1 year ago #

    Currently if the post is Draft or Pending Approval the validation for unique field does not work due the SQL query on row 125.

    Row 125 should be modifies and
    and p.post_status = 'publish'
    replaced with
    p.post_status IN ( 'publish', 'pending', 'draft', 'future', 'private' )

    https://wordpress.org/plugins/validated-field-for-acf/

  2. doublesharp
    Member
    Plugin Author

    Posted 1 year ago #

    To provide backwards compatibility I implemented this in a slightly different way. When you choose a unique type you can now select if you want it to apply to all or just published posts. The default is "No" for just published posts, if you select "Yes" it will query across posts types by omitting this field from the SQL query.

    Please update to version 1.0.5, thanks!

  3. ikivanov
    Member
    Posted 1 year ago #

    Thanks for you work. You may want to take different approach though.

    The best will be with check boxes to pick all possible post statuses. If this is impossible, then you need to add more options to choose from with vary of combinations following some logic.

    See: https://codex.wordpress.org/Post_Status

    Currently if you omit the post status it will return error for one that already have been deleted (trash), or auto-draft, or inherit. That may make this functionality useless.

  4. doublesharp
    Member
    Plugin Author

    Posted 1 year ago #

    @ikivanov Update coming soon with checkboxes for each of the status types you want to check. A few major bug fixes as well, just finishing up the testing.

  5. doublesharp
    Member
    Plugin Author

    Posted 1 year ago #

    @ikivanov please update to v1.0.6, you should not be able to select the post statuses that apply for each uniqueness query.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields: Validated Field
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags