• Resolved Ivo Slavík

    (@aiwo)


    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

    (@vbonamy)

    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

    (@aiwo)

    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

    (@vbonamy)

    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!

    Thread Starter Ivo Slavík

    (@aiwo)

    Now it works as expected, thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.