0
votes

I'm working on an e-commerce X-Cart based that has included a blog part. On my site files I have a folder "blog" where, inside, I have all the WordPress folders, files and so on.

A few weeks ago the site was moved on another server by the host and the PHP version was upgraded from 5.x.x to 7.x.x and that created some problems. The one I can't solve is that I can't login in the admin panel from WP. I always get the error "Sorry, you are not allowed to access this page".

I tried to disable all plugin and theme and nothing changed. Than I created a new admin user from MySQL and same. Using debug I get only this error:

PHP Notice: Undefined index: HTTP_X_FORWARDED_PROTO in httpdocs/blog/wp-config.php on line 93".

The complete code on the line is

require_once(ABSPATH . 'wp-settings.php');
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
   $_SERVER['HTTPS']='on';

But I'm not sure could be linked to the admin login problem.

Any suggestions? I have even seen that my version.php file has $wp_version = '5.0.7'; and $required_php_version = '5.2.4.' .

Thanks a lot.

1
How exactly did you create this new username? Share the code you used for that, chances are you didn't assign the permissions correctly hence the reason why WordPress won't let you access the dashboard. - cabrerahector
INSERT INTO mydatabase.wp_users (ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) VALUES () INSERT INTO mydatabase.wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, 'my ID', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); INSERT INTO databasename.wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, 'my ID', 'wp_user_level', '10'); - Luchiii
Asides from the fact that you have an empty VALUES() in there (I'm guessing you removed it for security reasons? Or maybe you forgot to fill in that part of the query?), make sure the prefix wp_ seen in the query is the same one your site uses. - cabrerahector
Yes yes, I removed for security but I'm pretty sure that the problem is not there. Something went wrong during migrations and, right now, the admin panel is blocked or something. DB is working well I think because the front office as no problem. Users can even comment and It works fine. - Luchiii
Yes, but the problem (as I said before) is user permissions. WordPress thinks that that user doesn't have the right permissions (or any permissions at all) and so it won't let you access the dashboard. Something went wrong when you ran that query so you'll want to review it. - cabrerahector

1 Answers

0
votes

You need to check if HTTP_X_FORWARDED_PROTO is set. Try this:

if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)