---
title: newrelic_set_user_attributes (PHP agent API)
source: https://docs.newrelic.com/docs/apm/agents/php-agent/php-agent-api/newrelic_set_user_attributes
---

## Syntax

```php
newrelic_set_user_attributes(string $user_value, string $account_value, string $product_value)
```

Create user-related custom attributes. newrelic_add_custom_parameter is more flexible.

## Requirements

Agent version [3.1.5.111](https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes/php-agent-315111) or higher.

## Description

> #### 💡 TIP
>
> This call only allows you to assign values to pre-existing keys. For a more flexible method to create key/value pairs, use [`newrelic_add_custom_parameter`](https://docs.newrelic.com/docs/agents/php-agent/php-agent-api/newrelic_add_custom_parameter).

As of release 4.4, calling:

```php
newrelic_set_user_attributes("a", "b", "c");
// is equivalent to calling these three methods:

newrelic_add_custom_parameter("user", "a");  
newrelic_add_custom_parameter("account", "b"); 
newrelic_add_custom_parameter("product", "c");
```

All three parameters are required, but they may be empty strings.

## Parameters

| Parameter                 | Description                                                                                                                                       |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$user_value` _string_    | Required (can be empty string). Specify a name or username to associate with this page view. This value is assigned to the `user` key.            |
| `$account_value` _string_ | Required (can be empty string). Specify the name of a user account to associate with this page view. This value is assigned to the `account` key. |
| `$product_value` _string_ | Required (can be empty string). Specify the name of a product to associate with this page view. This value is assigned to the `product` key.      |

## Return values

This function will return `true` if the attributes were added successfully.

## Examples

### Record three user attributes [#record-three]

```php
function example() {
    if (extension_loaded('newrelic')) { // Ensure PHP agent is available
        newrelic_set_user_attributes("MyUserName", "MyAccountName", "MyProductName");
    }
}
```

### Record two user attributes and one empty attribute [#record-two]

```php
function example() {
    if (extension_loaded('newrelic')) { // Ensure PHP agent is available
        newrelic_set_user_attributes("MyUserName", "", "MyProductName");
    }
}
```
