Trouble with User Role to Post Relationship

Support MB Relationships Trouble with User Role to Post Relationship

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33851
    Ranadeep GhoseRanadeep Ghose
    Participant

    I am using the MB Builder and I have created a relationship Users to Contacts.

    I have entered user_role in the Query args key field and subscriber in the value field. But the metabox shows all users instead of only those with subscriber role.

    I have also tried entering role__in in the Query args key field with the same result.

    The idea is to assign only Users with the subscriber role to Contacts.

    Please help.

    #33866
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you want to use one role subscriber, just use the argument role, like this

    function your_prefix_function_name() {
        MB_Relationships_API::register( [
            'id'   => 'user-to-post',
            'from' => [
                'object_type' => 'user',
                'field'       => [
                    'query_args' => [
                        'role' => 'subscriber'
                    ],
                ],
            ],
            'to'   => 'post',
        ] );
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.