Issue with role__in query arg to get users with specific roles

Support Meta Box AIO Issue with role__in query arg to get users with specific roles

  • This topic has 1 reply, 2 voices, and was last updated 1 week ago by PeterPeter.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #48732
    DIDIER FELICITEDIDIER FELICITE
    Participant

    I’m having an issue with the user field type in Meta Box. I want this field to list only users with specific roles (e.g., administrator, vendor). In the Query args fields, I entered:

    role_in -> administrator, vendor

    but this doesn’t work because the role__in parameter in WP_User_Query requires an array of values, like:

    'role__in' => ['administrator', 'vendor']

    However, when I generate the PHP code from Meta Box — even using your online generator — I get:

    'role__in' => 'vendor, administrator'

    which is incorrect.

    My question is: does the Meta Box UI Query args parameter support multiple user roles?

    Best regards,

    Didier

    #48740
    PeterPeter
    Moderator

    Hello,

    Yes, you can pass multiple values to an argument by using the dot notation.
    role__in.0 => vendor
    role__in.1 => administrator

    Please follow the documentation https://docs.metabox.io/extensions/meta-box-builder/#dot-notation

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