Hi,
Yes, the -NCONTAINS operator should work as expected in this case. However, it’s important to note how CAS{roles} is interpreted:
- If
roles is single-valued, it is treated as a simple string.
- If
roles is multi-valued, its string representation (i.e., the serialized array) is used for evaluation.
Given this, -NCONTAINS is a reasonable choice for your use case. However, depending on the scenario, -IN/-NOTIN might sometimes be preferable when dealing with multi-valued attributes, as they evaluate individual elements rather than the entire string representation. But in your specific query, -NCONTAINS remains suitable.
Best regards,
Vincent.
Ok, in my case CAS roles is multi-valued array. I need to set two types of WP roles to logged in users:
- subscriber for those whose CAS roles doesn’t contain “ABC” and “DEF” strings, I use
(CAS{roles} -NCONTAINS “ABC”) -AND (CAS{roles} -NCONTAINS “DEF”) and it doesn’t seem to work – new WP user has no role set.
- contributor for those whose CAS roles contain “ABC” or “DEF” strings, I use
(CAS{roles} -CONTAINS "ABC") -OR (CAS{roles} -CONTAINS "DEF") and it works fine.
-IN/-NOTIN doesn’t work either. Thank you.
This issue has been addressed in version 2.3.7.
The -NCONTAINS and -NOTIN operators should now work as expected.
Please update to the latest version and let us know if you encounter any further issues.
Thanks for your feedback!
Now it works as expected, thank you very much!