Unique value of Text field on a whole site

Support General Unique value of Text field on a whole siteResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18815
    Trang NguyenTrang Nguyen
    Participant

    Hi, is it possible to have unique value of a Text field of each post on a whole site (one unique value for each post/custom post type, similar to ID for each post).

    Let say I have a Places custom post type and a Text field called Code.
    For each place, I want to set a code (text+number) in the Code text field and two places can not have a same code.

    Ex:
    Place 1 has code VNSG001
    Place 2 has code VNSG002
    Place 3 has code VNSG003
    If I write VNSG001 or VNSG002 on the place 3 and click Publish/Update, it will show error and ask to change the value that doesn't exist.

    Thank you.

    #18821
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Unfortunately, the plugin Meta Box does not support to check/validate the value in a field is unique or not. But you can use the post ID of WordPress itself (unique) to concatenate with your field value when printing out on the front end

    echo rwmb_meta('field_id') . get_queried_object_id();

    #18822
    Trang NguyenTrang Nguyen
    Participant

    Thank for your information!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.