Restrict results to be shown and sent to specific registered members
Hi,
I have a membership website. In my website I have 2 types of registered users, free membership users and a paid membership users. I am using save results pro with HD Quiz, and would like everyone to be able to take the quiz however only paid membership users are capable to see their results and get them sent to their emails. Is it possible to do this? I am using woocoommerce, elementor pro.
Best regards
KJA
Hi Khaled,
yes, this is possible! But it requires several things.
I am basing my answer off of the following assumptions.
- All quiz takers will be logged in
- You want to A) restrict both the results that appear once a quiz has been completed to only the paid users, AND, B) only send the results email to those same users.
A) is doable now. I can provide you with a custom function that you can add to your theme’s functions.php that on quiz load, will check to see what capabilities the current user has. If the current user does not have the needed capability (IE: Whatever ones your paid users have), we force hide the results.
B) Will require me to make a minor update to the Save Results Pro addon. The update will add in a filter to the function that decides if we should send an email to the user or not. With this new filter, I can again send you a custom function that checks who the current user is and if they have the needed capability.
What I need from you
I need to know what capabilities your paid users have that your free ones do not. If you don’t know this, then I will need to know the exact name of the user role for your paid users. Examples: subscriber, author, editor, admin. Your paid users will be named something else. If you need help with this let me know.
Hi Dylan,
Thanks for your quick and informative response. Both free and paid users can take the quiz, however, the free ones can see the initial results only whereas the paid users can see the initial results and get the detailed ones to their emails. The paid users group are called the golden membership.
Regarding the custom function you may send to me, I am afraid it will malfunction or stop working after any update of the plugin. Is there any turn round or a permanent update for the plugin to offer such feature.
Regrads
> I am afraid it will malfunction or stop working after any update of the plugin
No need to worry; this is the whole reason I’d use a filter to add this functionality in for you. Doing it this way means that you can continue to update both HD Quiz and the SRP addon without removing the custom functionality.
The only barrier is your comfort in adding this code to your theme’s functions.php file. If you are willing to provide me with access to your site, I can do this for you — just let me know, and I’ll contact you via email so you can send me credentials privately.
Currently, still working and testing in a local hosted copy of the site on my PC. I usually use a code snippet plugin to add functions to my functions.php. Would that be fine for you?
If yes, you may put the modifications needed here or send them to my email.
Best regards
Hi Khaled,
just letting you know that I’m still working on this, but will have a solution ready for you early next week (probably Monday)
Hi, Dylan
I appreciate your efforts. Take your time.
All done!
I’ve pushed out an update to the addon. You can either wait for your site to check for the update and then update through WordPress as normal (note: The addon only checks for updates once a week), or redownload the addon using the link that was sent to you.
Now that the Save Results Pro addon has been updated to include the aforementioned filter, you can now download this additional custom addon I created for you.
HDQ_SRP_NOTIFICATIONS_ADDON.zip
NOTE: Make sure that you enable “Send results to the quiz taker” in the SRP settings.
In order for the addon to work, you will need to edit index.php file of the addon and change line 41, the text role_id_of_your_needed_user to be the name of the role of the users you want to send the email to.
Once done, this addon will hook into the Save Results Pro function that sends emails and check to see what the current user’s role is. It will then only send to that user if their role matches what you enter above on line 41.
This works by using the actual ID of the role, not the “label”. So you cannot just enter “golden membership”. You’ll need to find out what the actual name of that role is.
Because of this, I also included a new shortcode called hdq_srp_get_roles_list that will list out all the available roles on your site. Add this shortcode to any page or post to see it. You can use the shortcode to find the role that makes most sense.
Of course, once all ready, make sure to do a test to ensure you are using the correct role 🙂
wow
Nice improvements. That’s really great for the add-on. I will try the new updates soon and let you know my feedback. I have another feature to suggest if you don’t mind. I was thinking if there is a possibility to have HD Quiz control the way it shows the quiz to users according to their roles. For example, non-logged in users can take a quiz that has for instance 15 questions, but the quiz will show only a specific number of questions (assigned by the admin) then the quiz will ask them to login or register in order to complete the quiz. Where as the logged in users can take the full quiz and see their final results immediately when the finish.Further more, users of a specific role (assigned by the admin) can see their results and are granted to send detailed reports to their emails.
What do you think, would that be possible and useful feature?
Best Regards
I’ll try my best to break this all down, but I want to start by saying that there is a world of a difference between “totally possible to do this”, and “This is something I think is a good idea to build in”.
> HD Quiz control the way it shows the quiz to users according to their roles.
Totally possible. The FREE Limit Attempts addon is an example of how HD Quiz can be extended to either show or hide the quiz depending on if the current user is logged in. It’s possible to take the same concept, except instead of simply checking if the user is logged in, we can also check what their role is.
> For example, non-logged in users can take a quiz that has for instance 15 questions, but the quiz will show only a specific number of questions (assigned by the admin) then the quiz will ask them to login or register in order to complete the quiz. Where as the logged in users can take the full quiz and see their final results immediately when the finish.
This would be best accomplished by creating two different quizzes. A “demo” quiz for non logged-in users, and the “full” quiz for registered users.
The problem here is that I’m assuming you want to save the current state of their quiz so they can pick up again where they left off. This is something that you can do with HD Quiz, but it would require a lot of custom functionality so that it works well with whatever your registration process is, as well as custom functionality to securely set the “full” quiz answers based on the logged-in users demo results (if exists. We’d have to use their email as their unique ID).
> Further more, users of a specific role (assigned by the admin) can see their results and are granted to send detailed reports to their emails.
This is basically what I just built for you 🙂
This thread has either been marked as complete or has been automatically closed due to inactivity. Please consider opening a new support thread for help.