How to get student name and id from WordPress learndash LMS
Jul 03, 2020
Hello all,
Can anyone help me on how to retrieve the student name and mail id from Wordpress Learndash LMS.
I have gone through various thread and nothing works.
Please check the below code.
var player = GetPlayer();
function findLMSAPI(win)
{
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var mailid = lmsAPI.GetStudentID();
var name = lmsAPI.GetStudentName();
var nameArray = name.split(",");
var firstName = nameArray[1];
var lastName = nameArray[0];
var player = GetPlayer();
player.SetVar('fname1',firstName);
player.SetVar('lname1',lastName);
player.SetVar('mail1',mailid);
alert(firstName,"FN");
alert(lastName,"LN");
alert(mailid,"email");
1 Reply
The LMSAPI method is not going to work in Learndash as it is not an LMS, you either need to use PHP to get the username from Wordpress or if you are using an LRS such as Grassblade you should be able to parse it from the url.
This post was removed by the author
This discussion is closed. You can start a new discussion or contact Articulate Support.