NextGEN Gallery – restore lost capabilities

If you accidentally lost capabilities created by NextGEN Gallery this post will give you the tool to restore them. Create restore-ng-caps.php file at the wp-content/mu-plugins/ folder. Insert code quoted below to that file.

function restore_lost_capabilities() {
    global $wp_roles;
    $caps_to_restore = array(
        'NextGEN Gallery overview',
        'NextGEN Use TinyMCE',
        'NextGEN Upload images',
        'NextGEN Manage gallery',
        'NextGEN Manage others gallery',
        'NextGEN Manage tags',
        'NextGEN Edit album',
        'NextGEN Change style',
        'NextGEN Change options',        
        'NextGEN Attach Interface'
    $role = $wp_roles->get_role('administrator');    
    foreach($caps_to_restore as $cap) {
        if (!$role->has_cap($cap)) {
            $role->add_cap($cap, true);
add_action('admin_init', 'restore_lost_capabilities');

Open your blog admin dashboard. Check with User Role Editor that capabilities were restored. That’s it. You may delete restore-ng-caps.php file now. It is the “one-time” but universal helper. You may use it easily, in case you need to add a lot of capabilities. Just replace the content of $caps_to_restore array.

Pay attention that in general WordPress capabilities are in lowercase letters and without spaces inside, e.g. 'edit_others_posts'. Thus, if you use “Show capabilities in human readable form” option, switch it off temporarily in order to see inner presentation of capabilities names valid for use in WordPress API.

P.S. Do not forget that any file with PHP code should start from <?php at the 1st line.
If you have a question – What is that ‘mu-plugins’ folder created for? – you may find the answer here.

You may download ready to use PHP file with code above here.

  • Vanessa

    Hi I have tried to use this file as I have lost the capability of accessing the Next gen gallery plugin under administrator role when I changed all the caapabilities to shop manager so my client can use it, however its not appearing for any role now. So I tried to use your file but i keep getting parse error messages saying the syntax is incorrect. eg Parse error: syntax error, unexpected ‘[‘ in /home/countryi/public_html/wp-content/mu-plugins/must-use.php on line 7. Any Ideas?

    • Hi Vanessa,

      Code above uses PHP 5.4 syntax to define array via square brackets:
      Try replace square brackets to this variant compatible with earlier PHP versions:

      $caps_to_restore = array( /*the same content inside*/);

      • Vanessa

        Thank you, that worked perfectly!! I was tearing my hair out about the lost capabilities, so thank you so much!

        • Good!
          Thanks to you for letting me know about code incompatibility. I updated the post and added the download link to ready to use PHP file.

  • gwsindia

    Thanks A lot.. 🙂

  • This solution still works as of NextGen version 2.0.66 on WP 3.9.1.

    Thanks so much – I wasn’t sure how I was going to restore the capabilities after (somehow) completely removing all NextGen Dashboard access for users of all levels!