Skip to main content
  1. Home
  2. Knowledge Base
  3. eLearning Magic Toolkit - Capture User Name From WordPress
  4. Grabbing The User Name Of The Current User From WordPress (To Use As Storyline Variables)

Grabbing The User Name Of The Current User From WordPress (To Use As Storyline Variables)

Grabbing The User Name Of The Current User From WordPress

Using the eLearning Magic Toolkit plugin, you can capture the currently signed in user’s name (accessing your Storyline learning content on the website page) in order to import the first and last name as text variables using JavaScript, ensuring that your Articulate Storyline project is embedded onto the page as an iframe or lightbox. If no name is detected, the variable values will default to ‘Guest’, allowing you to perform validation routines inside your project.

Here are the steps to perform in order to make this work inside of your own Articulate Storyline projects published to your WordPress site:

Step 1

Start by ensuring the plugin is activated and registered, as well as making sure you are running the latest version of LearnDash LMS.

Step 2

A new metabox will become available on all edit pages for LearnDash lessons and topics, allowing you to select which specific pages you wish to include a JavaScript reference to the learner’s name on the page.

Step 3

Prepare your Storyline project by including the following JavaScript code to run before any other actions take place on the slide. You should also create two new text variables called ‘firstname’ and ‘lastname’ to store the name variables:

var player = GetPlayer();

var firstname = window.parent.slfirstname;
var lastname = window.parent.sllastname;


player.SetVar("firstnamevariableinproject", firstname);
player.SetVar("lastnamevariableinproject", lastname);

Step 4

It is recommended that you include some validation triggers within your project. By default, if no first name or last name is detected for the user, or if the user is a signed out and is viewing the course page as a guest, then by default the JS variables for ‘firstname’ and ‘lastname’ will default to ‘Guest’.

Using this you can, for example, create a trigger which will prompt the learner to manually input their name if the ‘firstname’ of Guest is detected when the slide first loads.

In this trigger example we are sending the user straight onto the slide which welcomes them to the course if the lastname variable value IS NOT ‘Guest’. This signifies that the Storyline project has captured the learner’s name to variables and therefore we do not need for them to type their name manually.

Step 5

Publish the project to your LearnDash lesson or topic page either within an iframe or a lightbox window.

If you need further information on best practice for embedding Storyline content onto a web page, use this Articulate Storyline help guide.

Read the rest of our Knowledge Base pages to make the most of the eLearning Magic Toolkit.

Was this article helpful?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.