I have a WordPress site using BuddyBoss and LearnDash to support an online learning community. I am using Auth0 to provide SSO across a network of member sites employed by this organization. I have the sites set up as Machine to Machine applications that share a database. We use a custom database action script to login and get users. Everything works perfectly, except when users register for the site using a custom signup url provided by LearnDash Groups.
This signup page registers users for the site and enrolls them in the group, giving them access to certain courses, etc. After successful registration in WordPress, the user is not able to login. Upon checking Auth0 for an error, I notice the user is never created or seen as logging in. The user is visible in WordPress and enrolled in the proper groups, etc. When I try to login, the error is: DB Login Custom script: user_id is required, please update the import user script in the connection settings.
Please see Get User script below:
/* globals require, configuration /
/*
-
This script will be executed when the user wishes to change their password to test if the user exists.
-
This needs a global configuration option with the following properties:
-
{string} endpointUrl - Site URL with an empty “a0_action” parameter appended.
-
{string} migrationToken - Migration token found in the plugin settings
-
{string} userNamespace - Formatted site name to avoid user ID overlapping.
-
@param {string} email - User email address, provided on login.
-
@param {function} callback - Function to call when the script has completed.
*/
function getByEmail(email, callback) {
“use strict”;
const request = require(‘request-promise@1.0.2’);
const Promise = require(‘bluebird@3.4.6’);const authenticate = Promise.coroutine(function *() {
//gets the user profile from the both application
let wpUser;
let profile = {};try {
wpUser = JSON.parse(yield doRequest(email, configuration.migrationToken, configuration.endpointUrl + ‘migration-ws-get-user’));profile = { user_id: configuration.userNamespace + '|' + wpUser.data.ID, username: wpUser.data.user_login, email: wpUser.data.user_email, name: wpUser.data.display_name, email_verified: true }; } catch (e) { }
try {
wpUser = JSON.parse(yield doRequest(email, configuration.migrationToken2, configuration.endpointUrl2 + ‘migration-ws-get-user’));profile = { user_id: configuration.userNamespace2 + '|' + wpUser.data.ID, username: wpUser.data.user_login, email: wpUser.data.user_email, name: wpUser.data.display_name, email_verified: true };
} catch (e) { }
return callback(null, profile);
});authenticate().catch(function(e) {
return callback(new Error(e));
});function doRequest(email, token, url) {
const options = {
method: ‘POST’,
url: url,
formData: {
username: email,
access_token: token
},
};
return request(options);
}
}