TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.76k stars 430 forks source link

WP4.0 MU i get permission error. #228

Open parkmap opened 10 years ago

parkmap commented 10 years ago

I got a "You do not have sufficient permissions to access this page." error on /wp-admin/network/themes.php?page=tgmpa-install-plugins

current version is wordpress 4.0 Multisite

BeFiveINFO commented 10 years ago

Hello,

I guess I just had the same problem as yours only on multisite of wp 4.0.

Around Line #221 of the TGM_Plugin_Activation class file (class-tgm-plugin-activation.php) https://github.com/thomasgriffin/TGM-Plugin-Activation/blob/master/class-tgm-plugin-activation.php

Modify the line: -add_action( 'admin_menu', array( $this, 'admin_menu' ) );

To:

Note: you have to use double quotes for bracketing "{$hook}admin_menu".

reference: http://stackoverflow.com/questions/13960514/how-to-adapt-my-plugin-to-multisite (see Adding an admin page)

In MU, the hook name had to be "network_admin_menu" for the plugin to register the menu item (the function was not being called with the admin_menu hook name).

Hope that this helps.

parkmap commented 10 years ago

Thanks BeFiveINFO for the detailed reply,

I just replaced with -add_action( 'admin_menu', array( $this, 'admin_menu' ) );

To:

$hook = ismultisite() ? 'network' : ''; add_action("{$hook}admin_menu", array( $this, 'admin_menu' ) );

however,

I still get same message when I click the Begin activating plugin

"You do not have sufficient permissions to access this page." error on /wp-admin/network/themes.php?page=tgmpa-install-plugins

let me know how to fix the problem.

Thank you

BeFiveINFO commented 10 years ago

Hello,

In my case, the error occurred because the installation page was not registered at all. The admin menu was not registered because the "admin_menu" function of the class was not called at "network_admin_menu" hook.

I can only suggest you to check up the followings:

  1. Is "your" TGM_Plugin_Activation class really defined? (any possibility of conflict with other plugins or a theme using the TGM_Plugin_Activation class?)
  2. Is the "Install Required Plugins" page really registered? (in order for the installation page to be registered the adminmenu in the class needed to be called by the "network admin_menu" hook) [edited to make it more precise]

The public function of admin_menu() of the class need to be called for the page to be registered. You can find the admin_menu function at the line #333. To see if the function is called, you can try for example "echo 'test';" at the line #334 to see if WordPress is calling the function.

Note: you can try the following lines to see currently registered admin menu items at any point:

global $_registered_pages; 
var_dump($_registered_pages);

To see if admin_menu() is really registering, you can try the code at right under the line #350.

Please let me know how it goes.

cconover commented 10 years ago

I am having the same issue. TGMPA is being handled by Composer. Works fine with the exact same setup on a non-Multisite install.

denisbosire commented 10 years ago

Been having this problem for a while as well, even though it was fixed on v2.2 here's how I fixed it. First remove the line " 'force_activation' => true," from within the $plugins = array(..) Then change the array " 'is_automatic' => false, " to true under the $config = array(..) Seems to be a conflict somewhere. Hope this helps

jrfnl commented 9 years ago

PR #247 applies this fix and also fixes the admin notice display for multisite.

CodingSamurai commented 9 years ago

Thank you this saved me after a couple of hours of frustration! This really should be rolled into V2.5 as a temporary fix until the restructured behaviour is built in 3.0

jrfnl commented 9 years ago

@CodingSamurai While I understand your point, as MS is not supported at this moment, we shouldn't be giving the impression that it is, which is why this will not be included in v2.5.

quitoxic commented 9 years ago

Hey, I have no experience so far with PHP and getting this problem, same thing multisite etc. I have been trying to follow the instructions on this thread but faild to make it work. Could any one help me out?

jrfnl commented 9 years ago

@quitoxic As indicated in the post just above yours: Multi-site is currently not supported by TGMPA nor could it be with the way it is set up at this moment. Making TGMPA multi-site compliant is one of our goals for version 3.0, but will involve major changes in how to indicate dependencies.