Title: -NCONTAINS operator
Last modified: March 18, 2025

---

# -NCONTAINS operator

 *  Resolved [Ivo Slavík](https://wordpress.org/support/users/aiwo/)
 * (@aiwo)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/ncontains-operator/)
 * Hi, should -NCONTAINS oparator work? Is this rule correct, when I search in roles
   not containing strings “ABC” and “DEF”?
 * (CAS{roles} -NCONTAINS “ABC”) -AND (CAS{roles} -NCONTAINS “DEF”)
 * Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [vbonamy](https://wordpress.org/support/users/vbonamy/)
 * (@vbonamy)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/ncontains-operator/#post-18369689)
 * 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.
 *  Thread Starter [Ivo Slavík](https://wordpress.org/support/users/aiwo/)
 * (@aiwo)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/ncontains-operator/#post-18370585)
 * 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.
 *  Plugin Author [vbonamy](https://wordpress.org/support/users/vbonamy/)
 * (@vbonamy)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/ncontains-operator/#post-18374081)
 * This issue has been addressed in [version 2.3.7](https://wordpress.org/plugins/wp-cassify/#developers).
 * 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!
 *  Thread Starter [Ivo Slavík](https://wordpress.org/support/users/aiwo/)
 * (@aiwo)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/ncontains-operator/#post-18374856)
 * Now it works as expected, thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘-NCONTAINS operator’ is closed to new replies.

 * ![](https://ps.w.org/wp-cassify/assets/icon-256x256.png?rev=3112582)
 * [WP Cassify](https://wordpress.org/plugins/wp-cassify/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-cassify/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-cassify/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-cassify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-cassify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-cassify/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Ivo Slavík](https://wordpress.org/support/users/aiwo/)
 * Last activity: [1 year, 1 month ago](https://wordpress.org/support/topic/ncontains-operator/#post-18374856)
 * Status: resolved