Skip to content

UserMetadata Criterion

The UserMetadata Search Criterion searches for content based on its creator or modifier.

Arguments

  • target - UserMetadata constant (OWNER, GROUP, MODIFIER); GROUP means the User Group of the content item's creator
  • operator - Operator constant (EQ, IN)
  • value - int(s) representing the User IDs or User Group IDs (in case of the UserMetadata::GROUP target)

Example

PHP

1
$query->query = new Criterion\UserMetadata(Criterion\UserMetadata::GROUP, Criterion\Operator::EQ, 12);

REST API

1
2
3
4
5
6
7
8
9
<Query>
    <Filter>
        <UserMetadataCriterion>
            <target>GROUP</target>
            <operator>EQ</operator>
            <value>12</value>
        </UserMetadataCriterion>
    </Filter>
</Query>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "Query": {
        "Filter": {
            "UserMetadataCriterion": {
                "target": "GROUP",
                "operator": "EQ",
                "value": 12
            }
        }
    }
}

Use case

You can use the UserMetadata Criterion to search for blog posts created by the Contributor user group:

1
2
3
4
5
6
7
8
9
// ID of your custom Contributor User Group
$contributorGroupId = 32;

$query = new LocationQuery;
$query->query = new Criterion\LogicalAnd([
        new Criterion\ContentTypeIdentifier('blog_post'),
        new Criterion\UserMetadata(Criterion\UserMetadata::GROUP, Criterion\Operator::EQ, $contributorGroupId)
    ]
);