# Traga o nível de permissão do WordPress MemberPress

**URL:** <https://meta.discourse.org/t/bring-over-permission-level-from-wordpress-memberpress/78074>\
**Category:** WordPress\
**Created:** [15 Janeiro , 2018 16:26 UTC](https://meta.discourse.org/t/bring-over-permission-level-from-wordpress-memberpress/78074 "2018-01-15T16:26:13Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [9 Junho , 2018 18:26 UTC](https://meta.discourse.org/t/bring-over-permission-level-from-wordpress-memberpress/78074/19 "2018-06-09T18:26:10Z")

</div>

> [@apautler](#):
>
> It works except when someone is a member of multiple memberships. In that situation it only applies the last group, which makes sense since it is looking for the latest value of $params.

You could try creating arrays for the groups you wish to add and remove. For each condition you check, add to the arrays. Something like the code below could be used inside of your function.

```plaintext
//...

$groups_to_add = [];
$groups_to_remove = [];

if ( /* some condition */ ) {
    $groups_to_add[] = 'group_one'; // $array[] = 'element' adds 'element' to the array.
    } else {
    $groups_to_remove[] = 'group_one';
}

if ( /* another condition */ ) {
    $groups_to_add[] = 'group_two';
    } else {
    $groups_to_remove[] = 'group_two';
}

//...

$params['add_groups'] = join( ',', $groups_to_add ); // Create a string from the array, with ',' as the separator.
$params['remove_groups'] = join( ',', $groups_to_remove );

return $params;

```

Make sure you are calling `join()` with no spaces in the separator parameter (`','`).

---

_[View the full topic](https://meta.discourse.org/t/bring-over-permission-level-from-wordpress-memberpress/78074)._
