THE DAILY GLADIATOR

Bonus Quiz

Bonus Quiz for logged-in users

Scroll to Top

How to use the Bonus Quiz page

  • Register a free account by clicking on “Register” in the top menu bar.
  • After log-in play the bonus quiz. Slide 2 of the quiz will show your logged-in status and display your username.
  • Then log-out using the top menu bar option “logout” and play the quiz again.
  • Slide 2 will now display a login form or a button to open the login form in a a pop-up

How this works

The site is sending a logged in status and the user display name to the Riddle data layer via Javascript (window.riddleDataLayer.push({ key: ‘display_name’, value: ‘$display_name’ });

Riddle checks if the logged in status is set to “logged-in”. If it is, Riddle’s branching logic proceeds to the info screen and displays the user’s display name. If the user is not logged it, the Riddle branching logic branches to the Riddle block type “Ad/I-Frame”. Inside this block type a barebones WordPress login form is loaded. Post login, the form does two things:

  1. It sends a

    window.parent.postMessage({ ‘ad-iframe-complete’: true } message to the Riddle iFrame, which tells the Riddle to advance after a successful login

  2. It passes the login info (username, email, login status) to an event listener on the page where the Riddle is embedded. This event listener then sends update login information back to the Riddle data layer. This way, post login, you will see the name of the logged in user displayed in the Riddle itself and the quiz data will be saved along with the login data.

Once the user is logged in, Riddle stores the user’s information (display_name and user ID) along with the data from the quiz.

The login data and status is also passed to the main WordPress site. As Riddle does not want to reload the main page though (which would reload the Riddle itself and kill all progress in the Riddle), the login status only updates when you either navigate away from the page or reload the page when the Riddle is finished. On your own site, you could of course update the navbar which shows the login status with AJAX or display a message outside the Riddle iFrame about the login status.