Support » Fixing WordPress » No wp-admin access anymore

  • Resolved Tom

    (@tomybyte)


    XAMPP Windows 7, PHP 7.2, WordPress version: 5.0.3 (Classic Editor Plugin activated)

    I’m developing a plugin for a WordPress website. All worked fine till yesterday. I made some experiments with redirect on user login depending on the user’s role. All worked as expected. Hours later I discovered, that after login each user has been redirected to the front page even my admin. And when I entered the backend URL (wp-admin) I got this: Sorry, you are not allowed to access this page. Even as logged in administrator. I googled a while and discovered many suggestions, what to do in this case. I cleared the browser cache and deleted the cookies, I removed all plugins from the plugins folder and all themes up to one basic theme (twentyseventeen). Nothing changed the scene. I created manually direct in the database a new admin user and could log in but still no access to the backend even for this new administrator.
    I looked at the .htaccess, but it was OK. And there is no .htaccess in the wp-admin directory. I completely replaced the wp-admin and wp-inludes folder with originally folders from a WordPress Installation of the same version.

    Yes I have a backup from the day before yesterday. And from the files and the database I can restore many of the changes I made yesterday. The already restored backup is working fine.

    But I’m scared, that this could happen any time to the production installation, when the plugin is done, as long I don’t know what happend and why. Was it my mistake, and what was the fault? Can WordPress meltdown in this way any time? Yes I’m scared as long I don’t know what happend and how I can repair it.

    Any ideas?

    • This topic was modified 1 year, 11 months ago by Tom.
    • This topic was modified 1 year, 11 months ago by Jan Dembowski.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello tomybyte,

    There is a high possibility that your Plugin code is conflicting somewhere which caused the issue.

    As normally it does not happen with WordPress, so I would suggest you to check your plugin code and see if you find anything problematic.

    Thanks,
    Kartik

    I’ve got the monster, that caused the trouble.

    It was the loco translator plugin:

    I detected that in the database of the corrupted website in the wp_options table the options_name key wp_user_roles had been everything deleted inspite of this: a:1:{s:10:”translator”;a:2:{s:4:”name”;s:10:”Translator”;s:12:”capabilities”;a:3:{s:4:”read”;b:1;s:10:”loco_admin”;b:1;s:12:”upload_files”;b:1;}}}

    So nothing worked any more, even not my plugin user specific functions and class methods.
    After updating the wp_user_roles key with the backup data, everything is back, even the wp-admin access.

    So I have to state: I won’t use the loco plugin any more – it is worse!!

    • This reply was modified 1 year, 11 months ago by Tom. Reason: misspelling
    • This reply was modified 1 year, 11 months ago by Tom. Reason: misspelling
    Tim W

    (@timwhitlock)

    My plugin adds capabilities, but doesn’t remove any other than its own. I’m not ruling out a bug, but it’s installed on 800k websites and nobody has reported this before. All the code is publicly available to scrutiny. The main entry point for setting up the “translator” role and the “loco_admin” capability is here: Loco_data_Permissions::init. As a plugin developer yourself, I’d appreciate it if you can spot a problem with any of the logic.

    Perhaps you could post your plugin, so I can test if there is a bug in mine?

    Tim W

    (@timwhitlock)

    Looking more at your example. You show that there is only one role, the “translator” role. Yes, Loco Translate will add this role if it doesn’t exist already. It then goes on to add the “read” and “loco_admin” capabilities if they don’t exist.

    How did you establish that Loco Translate deleted the other roles? or deleted other capabilities from this role? I’ve tried to reproduce this, and I can’t. Looking over the code I can’t see how it can happen either. Can you please provide steps to reproduce this?

    Worth noting too that your translator role has the “upload_files” capability that Loco Translate does not add. That suggests that you have at least one other plugin that uses the “translator” role. Is this the case? How did this role get the “upload_files” capability?

    I’m sorry. You are right. The result was what I wrote above, but it seems that not the Loco plugin was responsable for the disaster. Fact is, that I installed Loco short before the damage happend. But I did right before some experiments, copied from another place, when I wanted to translate the role labels in the backend:
    https://wordpress.stackexchange.com/questions/92529/is-there-a-way-to-localize-role-labels
    It was very likely the code from Johannes Pille – I tried. It does not work anymore in fact of the changes in WP core. So I transformed it a little bit and that may have caused the problems. Sorry I really forgot this.

    Hi admin – I was too quick with my allegation – Loco is no monster, may be it is a good plugin even it did not help me translate the user role labels in the users view in the backend. Can I edit my posts and correct that?

    Tim, I want to apologize for my harsh words.

    Tom

    • This reply was modified 1 year, 11 months ago by Tom. Reason: misspelling
    Tim W

    (@timwhitlock)

    OK, no problem. Thanks for being honest about your error.

    it did not help me translate the user role labels in the users view in the backend

    Any hard coded role names like _x('Contributor','User role'); can be translated via PO files. Loco Translate can help you with that as long as you can find the right PO file to edit. That will depend on where the role comes from. e.g. all core roles (like Contributor) are found in the admin-<locale>.po translation files. Translating them is then done by calling translate_user_role, although this is just an alias for calling the _x function as shown above.

    Loco Translate also provides a translatable string for the “Translator” role. It uses the same context as the core roles so that translate_user_role works.

    Other plugins will be responsible for providing their own strings, but my plugin can’t magically translate them for you. It’s just a file editor.

    Thank you Tim, I’ll have a look at this.

    I’ve had exactly the same issue. Admin, Editor, contributor roles (all 5 WP standard roles) were inexplicably wiped from the wp_user_roles field. No idea what caused it – but Loco Translate was updated around the time it happened…. coincidence?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘No wp-admin access anymore’ is closed to new replies.