Skip to content

Latest commit

 

History

History
66 lines (51 loc) · 1.65 KB

usermetadata_criterion.md

File metadata and controls

66 lines (51 loc) · 1.65 KB

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

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

REST API

=== "XML"

```xml
<Query>
    <Filter>
        <UserMetadataCriterion>
            <target>GROUP</target>
            <operator>EQ</operator>
            <value>12</value>
        </UserMetadataCriterion>
    </Filter>
</Query>
```

=== "JSON"

```json
{
    "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:

// 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)
    ]
);