DB_PREFIX='wr_'

Hi guys,

Wrapping my head about the following.
A client sent me a bedrock environment without the wp folder inside \web

Told me to install standard bedrock project which i did.
I copied the theme to \app and uploaded the .sql file with DB_PREFIX=‘wr_’ which has been updated in .env file!

The fresh bedrock project contains the wp folder, and when i refresh the url (i get prompted to create wp backend info).

The issue is that for the theme to load fully it has to be wr. But to access wp-admin it needs to be wp.

I’ve additionally inserted this in config/application.php

And also tried replacing all entries in the .sql file with new url and then ran “composer install” and “yarn” to build the theme; but same issue!

What is it i additionally need to do to fix this?

hehehehehe :rofl:

anything else you can chime in?

Why does the theme require a wr_ database prefix, while the Bedrock site doesn’t?
So the theme accesses the database? I mean, there is sometimes some blurring of separation between view and model. So wr_ is hardcoded in the theme code then, it doesn’t use an environment variable as Bedrock/WordPress does? Wouldn’t it be a better idea to just replace wr_ with the environment variable for the database prefix?

It happens that the db prefix has to be wr.
I managed to get to the wp backend by commenting: require_once(‘login.php’);
in themes\theme_xyz\appsetup.php

But now having issues to login, even after creating extra admin user directly in wr_users table.
This is the next challenge i need to overcome :slight_smile:

And you can’t just replace wr_ in the theme code with an environment variable?
Does the theme perform low-level SQL queries? This appears quite unusual.

At this point i don’t have enough knowledge to answer your 2 questions with precision.
Also considering with bedrock, sage theme lives under web\app\themes
while WordPress themes live under web\wp\wp-content\themes

And i am still figuring out how the bedrock ecosystem works.

The .sql file tables prefix is “wr_” and i think that’s all it should be; without the extra “wp_” tables that you get prompted if the DB_PREFIX= in the .env file is set to “wp”.
Prefix must be changed to “wr” otherwise you get prompted to create the wordpress backend info which is unnecessary!

Can you access/edit the theme code?
Are you developing locally, with version control (GIT) (hopefully)?

You could do a search for all occurrences of wr_ inside the theme folder (e.g. using Notepad++ or Visual Studio Code).
And then you can replace those wr_ string parts with the environment DB_PREFIX variable (env('DB_PREFIX')).

I have the theme with me locally on xampp.
No GIT involved yet. Will set it up after i build my 1st website with this theme.

I searched all wr_ occurrences and got 68 hits.
I am learning the theme and bedrock environment, but at this point i need to figure out why i cannot login to the back-end.

Thanks for your help so far! :slight_smile:

You have to exclude 3rd party code when searching through your project. A good IDE (as Visual Studio Code that is free) should already take the .gitignore file into account (even if you don’t use git, the file is there, as shown in the screenshot).
The screenshot contains lots of hits that are totally unrelated, from node_modules/ which contains the installed npm dependencies.

Maybe I misunderstand you but DB_PREFIX does (should) not affect the path of the wp-install which it sounds to me that you are saying it does pr you think it does. It only affects which DB tables WP is trying to use.

So if you change DB_PREFIX to ”wr_” and remove require_once(‘login.php’); that you mentioned above, can you access /admin or /wp-login.php (maybe wp/admin or wp/wp-login.php depending on your setup)? Note that you must not change the name of the wp-folder and if you have searched-replaced ”wp” to ”wr” that has to be undone.

Also, how did you create the user you mentioned? You cant add a password in plain text to the DB since it needs to be hashed. Try using wp user create | WP-CLI Command | WordPress Developer Resources or Wordpress Password Hash Generator . If you use the latter, just use ”12345” for example and dont paste your normal main password :slight_smile:

On a related note: WordPress Table Prefix: Changing It Does Nothing to Improve Security .

1st of all, thanks a lot for your reply! :slight_smile:
I won’t progress further without the help of those chimming in.

I think the only way to get past this, is to take things by steps, and cover the basics.

If DB_PREFIX does not influence the wp folder then i need to understand why i cannot login to the back end.

I haven’t searched-replaced anything.

The only way to get wp-login.php to load in the browser
is commenting line: require_once(‘login.php’);
in themes\wraith\app\setup.php

If the line is not commented
https://localhost/bedrock/web/wp/wp-login.php
reverts to
https://localhost/bedrock/web/wr-admin/
and throws error:

I created admin user following this article https://wpengine.com/support/add-admin-user-phpmyadmin/

And i added the Hash password directly in user_pass with MD5 selected
image

but get:

I am on the progress of setting up sendmail.php with another provider, since gmail is not working; to be able to use “Lost your password”.

The query generated by https://www.useotools.com/wordpress-password-hash-generator also fails:

DB_PREFIX shouldn’t affect the wp-folder, but maybe the previous dev has made it do so.

I guess if you try to change DB_PREFIX to something like “wq_” and see if you get redirected to /wq-admin will be the easiest way to find out.

If it doesn’t redirect to wq-admin, maybe the previous dev has done one of the things listed here: Renaming the WP-Admin Area – Loginizer, I guess you would have to check all the places mentioned in the article and/or search the entire project for “wr-” or “wr-admin”.

Another thing: judging by your URL in the browser screenshots, you probably haven’t set the docroot for Bedrock properly. See the next-to-last bullet at Bedrock: Installation | Roots Documentation . Its’ not related to the problem at hand but may be good to know.

Some more thoughts:

It could be that a plugin like Change wp-admin login – WordPress plugin | WordPress.org is being used to change the wp-admin path so you may want to check out the composer.json-file and web/app/plugins for any plugin that looks like it may do that.

If nothing turns up in the previous steps, does https://localhost/bedrock/web/wp/wr-admin/ work?

If all else fails, maybe you should set up a blank Bedrock install without any code you got from the previous dev but using the provided DB. Set DB_PREFIX to ”wr_” and see what happens. If it still redirects, its somewhere in the DB and if it doesnt redirect, start adding old code and test until the redirect happens.

Changing DB_PREFIX to “wq_” etc prompt’s wordpress install!

Will check about “Loginizer”.

The only plugin i have installed is “advanced-custom-fields-pro”; and composer.json is fine, as i did a blank bedrock install! I am not using the environment sent by the dev.

The only way not to be redirected is keeping commented line: require_once(‘login.php’);
in themes\wraith\app\setup.php

I use kaspersky internet security, and although turning it off prevents me from accessing localhost (it should have no impact on anything).

I will continue with testing :slight_smile: