wp-config.php settings recognized but not used
-
I’ve been able to get the login-with-google plugin working on my mutli-site WordPress installation by entering the client_id and secret in the Settings UI for each of the wordpress sites in my multi-site deployment. This was needed because I was unable to get the
wp-config.php
configuration settings to work.I added this to my
wp-config.php
/* https://www.ads-software.com/plugins/login-with-google/#description */ define('WP_GOOGLE_LOGIN_CLIENT_ID', '7935-REDACTED-nbfu.apps.googleusercontent.com'); define('WP_GOOGLE_LOGIN_SECRET', 'Tk-REDACTED-nh'); define('WP_GOOGLE_LOGIN_USER_REGISTRATION', 'false');
And I can confirm that the plugin is able to see these values because when I login using username/password and go to the login-with-google Settings UI, these 3 fields are greyed out and can’t be set, and the values that I’ve put in my
wp-config.php
are present in the fields in the Settings UI.The problem is that the plugin doesn’t seem to use these values if they’re configured in
wp-config.php
, only if they’re configured in the Settings UI.I’ve tested configuring the
client_id
inwp-config.php
and found that the “Log in with Google” button on the login page, which is a link to start the OAuth flow, has an emptyclient_id
value. This obviously causes the OAuth login to fail.I’ve also tested by setting the
client_id
in the plugin Settings UI and thesecret
inwp-config.php
. In this case, the “Log in with Google” button is correct and has theclient_id
but the OAuth flow fails because the plugin isn’t aware of thesecret
.I’ve read through the code and am assuming that this relates to the
utils/GoogleClient.php
and the__construct
method in theGoogleClient
class. This sets the$this->client_id
value using the$config
array that’s passed in.The array that’s passed in when the object is instantiated is in
src/Container.php
in thedefine_services
method of theContainer
class. I’m not familiar with the details here but I have to assumed that it’s only reading from the values set in the UI settings and ignoring anything set inwp-config.php
This should be reproducible on your side, just set the
client_id
andsecret
inwp-config.php
and see if you can login.If indeed you’re not able to reproduce this, let me know and I can share more details about my setup.
- The topic ‘wp-config.php settings recognized but not used’ is closed to new replies.