# Sign ups not working with custom Wordpress database connection

**URL:** <https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924>\
**Category:** Get Help\
**Tags:** custom-database-connections, connections\
**Created:** [May 26, 2023, 8:14pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924 "2023-05-26T20:14:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![developer6](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/developer6/32/12814_2.png) [@developer6](https://community.auth0.com/u/developer6)\
**Post date:** [May 26, 2023, 8:14pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/1 "2023-05-26T20:14:51Z")

</div>

Hi,

We’re using **Login by Auth0 v4.5.0** on **WordPress v6.2.2**. Users can create account through **custom database** connection and Google Social Login. We’re also using **Universal Login**. We’re using the standard login and get user scripts. Node 12 is used and we do not have any rule enabled.

This setup has been working just fine. Existing users can still login and new users can create an account via Google Social Login. However all of sudden our users started to have issues with creating an account using custom database connection.

Even though no change has been done, in order to be sure we’ve double checked the plugin and Auth0 configurations. Our hosting provider, WP Engine, looked at caching rules as well as how they handle Authorization headers, but they don’t find any issue.

When user tries to create an account they see “WE’RE SORRY, SOMETHING WENT WRONG WHEN ATTEMPTING TO SIGN UP.” message.

```auto
/index.php?a0_action=migration-ws-login
/index.php?a0_action=migration-ws-get-user

```

endpoints return **401: Unauthorized: missing authorization header** response.

We’ve reviewed all troubleshooting suggestions [here](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0) but didn’t get anywhere. [Here](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#unauthorized-missing-authorization-header) it’s suggested that the error we have is related to Authorization headers but our hosting provider doesn’t think so. The only thing they suspect is that CDN (they’re using Cloudflare) strips the headers before they hit the server. But this doesn’t explain why login is working while sign up via custom database is not.

Does anyone know what else we can investigate or even better a solution / suggestion that we can use?

Thank you

---

<div class="post-metadata">

**Author:** ![peter.fernandez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/peter.fernandez/32/45477_2.png) [@peter.fernandez](https://community.auth0.com/u/peter.fernandez)\
**Post date:** [May 27, 2023, 4:36pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/2 "2023-05-27T16:36:59Z")

</div>

> [@developer6](#):
>
> This setup has been working just fine. Existing users can still login and new users can create an account via Google Social Login. However all of sudden our users started to have issues with creating an account using custom database connection.

👋 @developer6 🤔 Signup using a custom database connection - leastways one that is not configured for user import - will typically utilize the user creation script (see [Create Script Templates](https://auth0.com/docs/authenticate/database-connections/custom-db/templates/create) for details). Have you double-checked to see that is working OK? If custom database login is working, and so too is login/signup via (Google) social connection, then I suspect that is probably where your issue lies 🙂

---

<div class="post-metadata">

**Author:** ![developer6](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/developer6/32/12814_2.png) [@developer6](https://community.auth0.com/u/developer6)\
**Post date:** [May 29, 2023, 8:15pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/3 "2023-05-29T20:15:28Z")

</div>

Hi @peter.fernandez,

Thank you for your response 🙂

To configure custom database, we’re using [the login script](https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-login.js) and [the get user script](https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-get-user.js) according to the guide [here](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#set-up-and-configuration). I’ve compared the scripts we’re using with the ones provided and they’re identical.

I’ve reviewed the logs again and now I see that not all users can login. There are lots of `Unexpected token < in JSON at position 0` and `Unknown client` errors at login, sign up and password change events.

---

<div class="post-metadata">

**Author:** ![peter.fernandez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/peter.fernandez/32/45477_2.png) [@peter.fernandez](https://community.auth0.com/u/peter.fernandez)\
**Post date:** [May 31, 2023, 9:39am UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/4 "2023-05-31T09:39:25Z")

</div>

> [@developer6](#):
>
> To configure custom database, we’re using [the login script](https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-login.js) and [the get user script](https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-get-user.js) according to the guide [here](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#set-up-and-configuration). I’ve compared the scripts we’re using with the ones provided and they’re identical.

Thanks for the update @developer6 🙂

The link you shared is to the user migration (to Auth0) guide. Does that mean you’re migrating your users to Auth0? Rather that leaving users credentials in your custom (credential) store? For user migration to Auth0, the custom database _login_ and _get user_ scripts should suffice. Though if you want to support a user resetting their password as part of a login attempt, you will also likely need to implement _change password_ too (see [Change Password Script Templates](https://auth0.com/docs/authenticate/database-connections/custom-db/templates/change-password) for details). Until a user is migrated to Auth0, password reset will typically be performed against your custom (credential) store.

However if you are not performing user migration and you are also looking to support Signup via Auth0, you will typically need to implement a _create_ script (see [Create Script Templates](https://auth0.com/docs/authenticate/database-connections/custom-db/templates/create) for more details) as well. In this situation - i.e. where users are not being migrated - the same would go for _change password_ too.

> I’ve reviewed the logs again and now I see that not all users can login. There are lots of `Unexpected token < in JSON at position 0` and `Unknown client` errors at login, sign up and password change events.

You might want to take a look at the troubleshooting section of the user migration guide [here](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#troubleshooting). This describes potential solutions for a number of situations, including the one it sounds like you’re currently experiencing (see [here](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#unexpected-token-in-json-at-position-0) for details).

Hope this helps 🕶

---

<div class="post-metadata">

**Author:** ![developer6](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/developer6/32/12814_2.png) [@developer6](https://community.auth0.com/u/developer6)\
**Post date:** [May 31, 2023, 5:39pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/5 "2023-05-31T17:39:22Z")

</div>

Hi Peter,

Yes, we’re performing user migration as we have a large user base that are not on Auth0. That’s why we’re using those scripts. Change Password is an issue and we’ll look into your recommendation when the sign up issue is solved.

`Unexpected token < in JSON at position 0` is the inital error we’re getting at sign up. We followed the troubleshooting recommendations [here](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#unexpected-token-in-json-at-position-0). Our `endpointUrl` is `https://examplewebsite.com/index.php?a0_action=`. According the documentation, this is how it should be but when we visit this URL, we get a 404. However if we add `migration-ws-login` or `migration-ws-get-user` to the endpointUrl, we get another error [Unauthorized: missing authorization header](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#unauthorized-missing-authorization-header). The suggested reason for this error is headers not being parsed. Our hosting provider investigated this and says that the headers are parsed.

For the record, the hosting provider is WP Engine and they’re using Cloudflare as CDN.

It looks like we’re stuck and no potential solution in sight.  
Thank you for the assistance anyway

---

<div class="post-metadata">

**Author:** ![peter.fernandez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/peter.fernandez/32/45477_2.png) [@peter.fernandez](https://community.auth0.com/u/peter.fernandez)\
**Post date:** [June 1, 2023, 1:43pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/6 "2023-06-01T13:43:36Z")

</div>

> [@developer6](#):
>
> Our `endpointUrl` is `https://examplewebsite.com/index.php?a0_action=`. According the documentation, this is how it should be but when we visit this URL, we get a 404. However if we add `migration-ws-login` or `migration-ws-get-user` to the endpointUrl, we get another error [Unauthorized: missing authorization header](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#unauthorized-missing-authorization-header). The suggested reason for this error is headers not being parsed. Our hosting provider investigated this and says that the headers are parsed.

Thanks for the clarification @developer6 🙂

I’m not a Wordpress expert, but looking at the code in the GitHub repository ([here](https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-get-user.js)) there are a few things I can suggest (in no particular order):

1. It looks like the endpoint - i.e. `/index.php?a0_action=migration-ws-login` - is expecting a `form` `POST`, so if you are trying to navigate to this (i.e. via `GET`) then this would probably explain why you are seeing [Unauthorized: missing authorization header](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0#unauthorized-missing-authorization-header). Perhaps try something like _Postman_ to perform the operation outside of Auth0 and see what you get? Naturally you’d ideally want to test against a test system, or failing that using a dummy user 🙂

2. 🤔 It doesn’t look like the request to Wordpress is failing otherwise `the callback(error)` would be driven. It looks more like the call to `JSON.parse` is failing given the error message you’re seeing. It’s likely throwing an exception (as described [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#exceptions)) and it’s likely doing so because the content of the `body` is not valid. Perhaps try adding a `console.log(body)` before the `var wpUser = JSON.parse(body);`? You should then be able to see the output using the [Real-time Webtask Logs Extension](https://auth0.com/docs/customize/extensions/real-time-webtask-logs). Again you’d ideally want to try this on a test system, using a dummy user 🙂

3. Perhaps try to wrap the code in the `request.post` callback function in an exception handling block? That way the exception can be caught. And you can perform a `return callback(null);` in the same way as the in the `if (wpUser.error || ! wpUser.data)` block (rather than an uncaught exception being thrown). As ever, you’d ideally want to try this change out on a test system, again using a dummy user 🙂

Hope this helps 🕶

---

<div class="post-metadata">

**Author:** ![agarcia](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/agarcia/32/47857_2.png) [@agarcia](https://community.auth0.com/u/agarcia)\
**Post date:** [June 6, 2023, 4:03pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/8 "2023-06-06T16:03:09Z")

</div>

Hello, I am having the same error. The content of the body in my code is showing up as HTML rather than JSON. Similarly we have had no changes in our environment recently that could cause this. Any ideas? Not sure what truly fixed the issue on this post.

I’ve started a new discussion here with more details: [Wordpress User Migration: Unexpected Token \< at position 0 - Auth0 Community](https://community.auth0.com/t/wordpress-user-migration-unexpected-token-at-position-0/108691)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 20, 2023, 4:03pm UTC](https://community.auth0.com/t/sign-ups-not-working-with-custom-wordpress-database-connection/107924/9 "2023-06-20T16:03:46Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
