Support

Account

Home Forums Backend Issues (wp-admin) Restrict meta value to only be assigned once Reply To: Restrict meta value to only be assigned once

  • Ah thanks John that makes sense,

    I will try and add a tax_query into the query and switch taxonomy/term value to belong to a field in the field group.

    FYI – The first section of your code in that posts caused a syntax error, heres the adjusted code that resovles the error.

    add_filter('acf/load_field/name=hidden_post_id', 'make_hidden_post_id_readonly');
    function make_field_readonly($field) {
      // sets readonly attribute for field
      $field['readonly'] = 1;
      return field;
    }
    add_filter('acf/load_value/name=hidden_post_id', 'set_hidden_post_id_value', 10, 3);
    function set_hidden_post_id_value($value, $post_id, $field) {
      // set the value of the field to the current post id
      return $post_id;
    }

    Working through your steps now hopefully I’ll have this working soon 🙂

    Thanks again!