This works well. I want to add in also all those who are not logged in who submit the front end forms to the website. I want all providers to see those forms. How would I add that into the search criteria?
I have tried: $clients[] = ''; and $clients[]='null' or is null, these are not working.
This is what I have found: If I use this search criteria I will filter in all those forms that were completed on the front end ‘non-logged in’ users, where ‘created_by’ is empty. If I change the oporator to is instead of in then an '' empty value works in search criteria. In this case all my clinicians can see the forms created on the front end from potential clients (that is part of what I want).
$search_criteria['field_filters'][] = array(
'key' => 'created_by',
'value' => '', // Search for entries where the value is empty
'operator' => 'is', // Use the 'is' operator to check for empty values
);
I would like to merge the results of both queries (this one in this post and the query in the first post) into one result. This way my clinicians will see only their logged in clients along with any general inquiries from potential clients. How might that be done?
This is the solution!! This merges the two queries:
$search_criteria = array(
'field_filters' => array(
'mode' => 'any', // or 'all' for OR logic
array(
'key' => 'created_by', // The meta key for the created_by user ID
'value' => '', // Search for entries where the value is empty
'operator' => 'is', // Use the 'is' operator to check for empty values
),
array(
'key' => 'created_by',
'operator' => 'in',
'value' => $clients
),
),
);
All is as I wanted. The mode needs to be any. I started with all and that was disappointing. I almost quit.