Hi I am really rubbish at code etc but manage to cobble stuff together some how.
I have a relationship field that I have got working setting my field as a post object.
This then pulls the email and contact number across for me to select in a another field group.
Currently it allows me to select more than one record, can anyone tell me how I can limit it so it only allow one record to be chosen.
This is the code I am using – it has a number 10 and a number 4 in it but I don’t know what these do.
`add_filter(‘acf/fields/relationship/result/name=customer_name’, ‘id_relationship_result’, 10, 4);
function id_relationship_result($title, $post, $field, $post_id){
// load a custom field from this $object and show it in the $result
$email = get_field(‘customer_email_address’, $post->ID);
$contactnumber = get_field(‘customer_contact_number’, $post->ID);
// append to title
$title = $email . ‘, ‘ . $contactnumber . ‘ ‘;
// return
return $title;
}
Not sure by reading if you’re using a post object or a relationship field.
The post object field has a setting for allow multiple, if it is off then only one should be able to be selected.
The relationship field has a “Max Posts” setting that can be use to limit the number of selections made.
Hi John thanks for that I’m using a relationship field