Question: I've created a custom user role and am attempting to change the users role from CUSTOMER to ADVOCATE on purchase of a particular product (using WooCommerce). I'm really close but struggling to get the correctly serialized data into my table: 

```
$order = new WC_Order( $order_id );
$items = $order->get_items();

$new_role = 'Array([advocate] => 1)';
$data = serialize( $new_role ); 

if ( $product_id == '786' ) {
    update_user_meta( $order->user_id, 'wp_capabilities', $data );
}

```

The correct table is being populated at the correct time but as

```
s:30:"s:22:"Array([advocate] => 1)";";

```

rather than what I need it to be which is

```
a:1:{s:8:"advocate";b:1;}

```

Where is my serialization tripping up?

Answer: 
In addition to syntax correction from WisdmLabs above I also found that I was effectively serialising the string TWICE as it will be automatically serialized when using update\_user\_meta. Not sure at which point I started serialising it myself but apparently that was completely unnecessary. 

<http://codex.wordpress.org/Function_Reference/update_user_meta>
The b in the serialized string means boolean. So you need to use true instead of one. And serializing it results in double serialization which explains "s:25:" in the beginning. Try this:

```
update_user_meta(46, 'wp_capabilities', array('employer'=>true));

```