# Wordpress Get User Function for Migration

**URL:** <https://community.auth0.com/t/wordpress-get-user-function-for-migration/117927>\
**Category:** Get Help\
**Tags:** custom-database-connections, connections\
**Created:** [October 5, 2023, 5:42pm UTC](https://community.auth0.com/t/wordpress-get-user-function-for-migration/117927 "2023-10-05T17:42:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afilazzola](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/afilazzola/32/51461_2.png) [@afilazzola](https://community.auth0.com/u/afilazzola)\
**Post date:** [October 5, 2023, 5:42pm UTC](https://community.auth0.com/t/wordpress-get-user-function-for-migration/117927/1 "2023-10-05T17:42:57Z")

</div>

I am following this guide for migrating users from a Wordpress database to Auth0

> **[User Migration in Login by Auth0 WordPress Plugin](https://auth0.com/docs/customize/integrations/cms/wordpress-plugin/user-migration-in-login-by-auth0)**
>
> Describes the user migration feature of the Login by Auth0 WordPress Plugin

There is a recommended code snippet here to hit the Wordpress DB to check if the use exists before consuming a token. However, this link is dead and when I try and generate a callback, I get cryptic errors.  
[https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-get-user.js](https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-get-user.js)

Anyone have suggestions what the code snippet should be? The following code returns an empty profile, which i’m fairly certain is because the URL endpoint isn’t configured correctly.

```auto
function getUser(email, callback) {
  const request = require("request");
  // Send user identifier to external database API
  let options = {
    url: configuration.endpointUrl,
    body: {
      email: email,
    },
    json: true, // Specify that the request and response should be JSON
  };

  request.post(options, (err, response, profileData) => {
    // Return error in callback if there was an issue finding the user
    if (err) {
      return callback(
        new Error("Could not determine if the user exists or not.")
      );
    } else {

      // Return null in callback if the user was not found, return profile data in callback if the user was found
      if (!profileData) {
        return callback(null);
      } else {
        
        let profile = {
          email: profileData.email,
  
        };

        return callback(null, profile);
      }
    }
  });
}

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 11, 2023, 1:19pm UTC](https://community.auth0.com/t/wordpress-get-user-function-for-migration/117927/3 "2023-10-11T13:19:29Z")

</div>

Hi @afilazzola,

Welcome to the Auth0 Community!

I think I found the old script. The URL looks like:

```auto
configuration.endpointUrl + 'migration-ws-get-user'

```

Here’s the old file, although I’m not sure why it was removed, so please take it with a grain of salt.

> <https://github.com/auth0/wordpress/blob/79eccf6e0f28fa1a9d15383f63c68789b972d3f4/lib/scripts-js/db-get-user.js>

---

<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:** [October 26, 2023, 2:26pm UTC](https://community.auth0.com/t/wordpress-get-user-function-for-migration/117927/4 "2023-10-26T14:26:30Z")

</div>

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