Title: array_merge error when Adding Role
Last modified: August 19, 2016

---

# array_merge error when Adding Role

 *  Resolved [johnkolbert](https://wordpress.org/support/users/johnkolbert/)
 * (@johnkolbert)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/array_merge-error-when-adding-role/)
 * Ok. I need some help. Please don’t recommend other plugins as a solution, I need
   to get this code to work.
 * I’m making a plugin that adds a new role when activated, populates it with the
   roles currently assigned to the “Administrator” role (and then do some other 
   stuff, not important for this question). Let me give you the code and then the
   error:
 *     ```
       function afterActivate(){
            global $wp_roles;
   
            $admin_role = $wp_roles->get_role("administrator");
            $role = $wp_roles->add_role("supr", "Super Admin", $admin_role->capabilities); //add super admin role
       }
   
       register_activation_hook(__FILE__, 'afterActivate');
       ```
   
 * THe problem is sometimes this works, and other times I get this error:
 *     ```
       Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /Applications/MAMP/htdocs/wp2pt7/wp-includes/capabilities.php on line 537
   
       Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /Applications/MAMP/htdocs/wp2pt7/wp-includes/capabilities.php on line 537
   
       Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /Applications/MAMP/htdocs/wp2pt7/wp-includes/capabilities.php on line 539
       ```
   
 * Does anyone have any idea what’s going on here? Any help would be greatly appreciated.
 * [moderated pointing to trac link [https://core.trac.wordpress.org/ticket/9128](https://core.trac.wordpress.org/ticket/9128)]

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [johnkolbert](https://wordpress.org/support/users/johnkolbert/)
 * (@johnkolbert)
 * [17 years ago](https://wordpress.org/support/topic/array_merge-error-when-adding-role/#post-999337)
 * This was fixed for 2.8.
 *  [xcaballe](https://wordpress.org/support/users/xcaballe/)
 * (@xcaballe)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/array_merge-error-when-adding-role/#post-999345)
 * I just upgraded to 2.8 and got this error message when editing a comment:
 * Warning: array_merge() [function.array-merge]: Argument #1 is not an array in[
   path]/wp/wp-includes/comment.php on line 1097
 * Warning: Cannot modify header information – headers already sent by (output started
   at [path]/wp/wp-includes/comment.php:1097) in [path]/web/wp/wp-includes/pluggable.
   php on line 865
 *  [Sarangan Thillaiampalam](https://wordpress.org/support/users/sarangan112/)
 * (@sarangan112)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/array_merge-error-when-adding-role/#post-999347)
 * xcaballe,
    I agree with you, because I get the same error in 2.8. I have tried
   in 2 different servers. 🙁

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘array_merge error when Adding Role’ is closed to new replies.

## Tags

 * [array_merge](https://wordpress.org/support/topic-tag/array_merge/)
 * [capabilities](https://wordpress.org/support/topic-tag/capabilities/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Sarangan Thillaiampalam](https://wordpress.org/support/users/sarangan112/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/array_merge-error-when-adding-role/#post-999347)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
