WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] array_merge error when Adding Role (4 posts)

  1. johnkolbert
    Member
    Posted 5 years ago #

    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 ]

  2. johnkolbert
    Member
    Posted 5 years ago #

    This was fixed for 2.8.

  3. xcaballe
    Member
    Posted 5 years ago #

    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

  4. sarangan112
    Member
    Posted 5 years ago #

    xcaballe,
    I agree with you, because I get the same error in 2.8.
    I have tried in 2 different servers. :(

Topic Closed

This topic has been closed to new replies.

About this Topic