A Simple Personality Quiz Using Formidable Pro

link to demo quiz using Formidable ProOne of the great reasons to use Formidable Pro is for how easy it is to create surveys and quizzes. A more difficult type of quiz to make, however, is the personality quiz because it requires evaluating a score assigned to each answer, then using the collected values to determine the results. For that reason, I’ve chosen to demonstrate how to do this by creating a simple personality quiz using Formidable Pro.

Demo Personality Quiz Using Formidable Pro



The way personality quizzes work is that each question relates to one of the possible personalities and, when answered, a value or score is assigned to that personality type. Once all the questions have been answered, the scores are totaled and evaluated to determine the winning personality. So the first thing our quiz needs is a set of questions.

In our demo quiz using Formidable Pro, Are You Chocolate or Peanut Butter, we created five questions using a Radio Buttons field for each. The field details are not all that important, but since our answers use words like yes, no and maybe, we also checked the option to use separate values and assigned a numeric value to each answer.

personality quiz using Formidable Pro question example

Notice that the question above is clearly a question that relates to the peanut butter personality and the values associated with each answer are a way of scoring the option as it relates to peanut butter.

For each of the first four questions in our quiz using Formidable Pro, two are peanut butter related questions and two are chocolate related questions. The higher the score in each question, the more likely it is that our quiz taker matches the related personality. (The fifth question is just for fun and not calculated into the winning score.)

It’s important to note that for a personality quiz to be effective, you will need to know a something about how to craft your questions to accurately predict the test takers personality. Since I don’t know anything about how to predict personalities, but I have life-long experience determining the difference between chocolate and peanut butter, I chose to keep my demo to a topic I know.

Scoring The Answers

Once you have some question fields and have created your values for scoring the answers, you will need some additional basic text fields to total these results. To start, create one field for each personality type.

quiz using formidable pro hidden total fields

As you can see in the image above, we have two fields for totals. One for peanut butter and one for chocolate. Their default values are created by adding the values of each related field.

To add up the values for each personality, you need to check the box to “Calculate the default value for this field” and enter each of the question field shortcodes, (field id surrounded by brackets), that are related to that personality type with a plus (+) between each shortcode. This becomes our math formula and now this field’s default value will be the sum of each related questions value. Do this for each personality type, adjusting the field ids as necessary.

I left this field visible in my demo, but for your quiz you will want to hide this field.

Determine The Highest Value

Now we need another field to evaluate each of the totals fields you just created and figure out which field holds the highest value. While we are doing this by calculating the default value again, we are going to be adding a slightly different math formula in the default value field to tell us this value.

quiz using formidable pro getting max value

The formula is very simple and looks like this:

What you need to change is the values of the Formidable shortcodes to match the IDs of your totals fields. If you have more than two personalities, add the shortcode for each related field, separated by a comma. This math formula will evaluate each value and save the highest one as the default value. If you are a PHP wiz, you could also replace the need for this field by doing the same evaluation in the PHP function coming up, but for this tutorial I wanted to keep as much of this method as possible within the standard form editor.

Ready To Add Some PHP… Well Almost

One last thing before we add our PHP function. We need a field to store the result we will get after processing the PHP function. This field will need to have some sort of value because if it’s left empty, the Formidable Pro hook we are going to use won’t be activated. This is why I created a field in my demo quiz called “The winner is…” and, most importantly, why it has a default value of “-” in it. It doesn’t matter what you add for a default value because our PHP function will remove it, but it needs something. Like the other total fields, this does not need to be visible to your users.

Now For The PHP

This bit of code is going to need several changes to match your exact field IDs and how you have structured your quiz using Formidable Pro. I added a lot of notes to explain what each piece of the function is doing, which should help you tweak it to your needs. This will need to be added to either your theme’s functions.php file, a custom plugin or using whatever method you are most familiar with for adding PHP to your WordPress site. I could write a whole tutorial on all the different ways to do this and the potential pitfalls so I have to assume you have a minimal understanding of how to safely add PHP to your site.

Be sure to read the code comments carefully. What this function will do is write either “chocolate”, “peanut butter” or “both” to the field where we’re storing our winning personality so we can use that value later in our view. For your quiz, you will want to account for all of the possible results, including a tie between personalities. If you have three types, such as A, B and C, the possible results would be A, B, C, AB, AC, BC and ABC so think this part out carefully.

Later In Our View

Now that you’ve created your simple quiz, how you choose to display the results–if you choose to display the results–is completely up to you. If you play with the my simple example, Demo Quiz Using Formidable Pro, you will see that the form redirects you to a page where I’ve inserted a fairly simple Formidable View. This view not only displays the value we set using the PHP function, but it also changes the image that is displayed based on that value using Formidable Pro’s conditional shortcodes.

Tip: If your quiz is long with many questions, break it up into multiple pages using Formidable Pro’s Page Break section fields. Just add your hidden fields to the final section.

I’d love to see how you take this example and make it your own. Feel free to leave a comment with questions or even a link to your own quiz using Formidable Pro.
demo quiz using Formidable Pro

1 Comment

  1. Amy on March 21, 2018 at 1:17 PM

    I noticed that this code is no longer working on my website anymore. When I went to your example quiz, it isn’t calculalting a winner either. I wonder if Formidable made an update that no longer supports this. Any idea how to update the code so it works again? Thanks.

Leave a Comment

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