Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP4.0 MU i get permission error. #228

Open
parkmap opened this issue Sep 26, 2014 · 10 comments
Open

WP4.0 MU i get permission error. #228

parkmap opened this issue Sep 26, 2014 · 10 comments

Comments

@parkmap
Copy link

parkmap commented Sep 26, 2014

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
Copy link

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:

  • $hook = is_multisite() ? 'network_' : '';
  • add_action("{$hook}admin_menu", array( $this, 'admin_menu' ) );

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
Copy link
Author

parkmap commented Sep 29, 2014

Thanks BeFiveINFO for the detailed reply,

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

To:

$hook = is_multisite() ? '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
Copy link

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 admin_menu 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
Copy link

cconover commented Oct 2, 2014

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
Copy link

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 added a commit to jrfnl/TGM-Plugin-Activation that referenced this issue Jan 13, 2015
As on multisite by default plugins can only be installed from the network admin, it makes more sense showing the TGM page in the network admin and not in the site admin.

On that same note, the admin notices should be shown on the network admin too.

Related TGMPA#228, TGMPA#239
@jrfnl
Copy link
Contributor

jrfnl commented Jan 13, 2015

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

jrfnl added a commit to jrfnl/TGM-Plugin-Activation that referenced this issue Jan 13, 2015
As on multisite by default plugins can only be installed from the network admin, it makes more sense showing the TGM page in the network admin and not in the site admin.

On that same note, the admin notices should be shown on the network admin too.

Related TGMPA#228, TGMPA#239

(cherry picked from commit ba8807e)
jrfnl added a commit to jrfnl/TGM-Plugin-Activation that referenced this issue Jan 13, 2015
As on multisite by default plugins can only be installed from the network admin, it makes more sense showing the TGM page in the network admin and not in the site admin.

On that same note, the admin notices should be shown on the network admin too.

Related TGMPA#228, TGMPA#239
@jrfnl jrfnl added this to the 3.0.0 milestone May 3, 2015
@jrfnl jrfnl mentioned this issue May 6, 2015
27 tasks
@CodingSamurai
Copy link

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
Copy link
Contributor

jrfnl commented Jun 5, 2015

@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
Copy link

quitoxic commented Aug 3, 2015

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
Copy link
Contributor

jrfnl commented Aug 3, 2015

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants