# Changing Category Permissions via API

**URL:** <https://meta.discourse.org/t/changing-category-permissions-via-api/42735>\
**Category:** Product Support\
**Created:** [18 Abril, 2016 17:04 UTC](https://meta.discourse.org/t/changing-category-permissions-via-api/42735 "2016-04-18T17:04:43Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)\
**Post date:** [18 Abril, 2016 18:17 UTC](https://meta.discourse.org/t/changing-category-permissions-via-api/42735/4 "2016-04-18T18:17:42Z")

</div>

OK, this will likely be due to array handling for parameters in PHP:

Change the function to:

```php
function editCategoryPermissions( $categoryId, $permissions, $username = 'system' ) {
  $params = array();
  foreach ( $permissions as $group => $permission ) {
    $params['permissions[' . $group . ']'] = $permission;
  }

  if ( empty( $params ) ) {
    // @todo consider throwing an exception here
    // sending empty parameters is most likely bad
  }
  return $this->_putRequest( '/categories/' . $categoryId, $params, $username );
}

```

And call as you did before:

```php
$r = $api->editCategoryPermissions( 641, array( 'admins' => 1 ) );

```

---

_[View the full topic](https://meta.discourse.org/t/changing-category-permissions-via-api/42735)._
