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.

Update – As of eLearning Magic Toolkit version 2.5.3, all WordPress Posts and Pages now feature the same metabox allowing you to activate Talk To The Learner functionality on any page of your site! Be sure to update to the latest version to take advantage of this.

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. If you want to use the plugin for LearnDash lesson and topic pages, make sure your LearnDash LMS plugin is up to date.

Step 2

A new metabox will become available on all edit screens for posts and pages, 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:

if (window.parent.slfirstname && window.parent.sllastname) {
    var firstname = window.parent.slfirstname;
    var lastname = window.parent.sllastname;

    setVar("firstname", firstname);
    setVar("lastname", 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 post or 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.

Leave a Reply

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