HD Quiz

Need to send invoices?
Check out my new WordPress plugin HDInvoice
Limited time launch sale

How to prevent editors from being able to edit other’s quiz settings and delete other’s quizzes?

Published: November 9, 2023
Support status: closed

Hi! Great app, but I have a small problem. I used User Role Editor to disable editors from ‘edit_others_posts’ and ‘delete_others_posts’ but editors are still able to edit the quiz settings and delete quizzes created by others. Is there any way to prevent this so an editor can only edit and delete their own quizzes?
It seems the questions themselves are removed from the editors’ view by disabling ‘edit_others_posts’.
Thanks for any help you can provide and apologies if I’m replicating a query but none turned up in my search.

thread author: Mat T

Hi Mat,
your timing with this question is incredible (skip all of this and just go to the bottom if you want the solution).

First, some quick advice (IE: me being pedantic). The whole point of an editor role is that they can do everything an admin can, except change the theme or edit code. They have full access to add and edit things like pages. It sounds to me that your editors shouldn’t be editors; they should be authors (or perhaps something custom). I of course don’t know your specific setup or needs, so this is just some general advice.

Now on to HD Quiz 🙂

The Explanation

One of the things that (in my very biased opinion) makes HD Quiz so powerful is that I built it using WordPress’ Custom Post Types and Custom Taxonomies. This allows HD Quiz to be fast, secure, and compatible, since it uses native WordPress functions to power most of the backend things.

However, in this case, it is the problem. You can think of Questions as blog Posts, and Quizzes as blog Categories. When you create a new post in WordPress, WordPress remembers and saves the author of that post. The same is not true for when you create a new category. WordPress does not care, or save, who the creator of a category is.

The solution

This is why I said your timing was incredible. Because the next version of HD Quiz (hopefully to be released tomorrow) will include two new functions to address this.

The first is that any newly created quiz will have the author ID saved as a hidden field. This will happen for all users for all new quizzes automatically. Just note the emphasis on new quizzes.

The second is that I will be introducing a new hidden setting called HDQ_EDIT_AUTHORED that when enabled, will make it so that the list of quizzes will only contain those authored by the current user (excluding admins of course who will always be able to see all quizzes).

The way for you to enable this new feature is to add the following to your theme’s functions.php file (make sure to backup this file first!!!).

define('HDQ_EDIT_AUTHORED', true);

09 November 2023 — 16:20 support admin - Dylan

Respond to thread

This thread has been closed / marked as resolved.
You can reply to this thread, but it might be better to start a new thread if you need help
.

You can also upload images to imgur and paste the links here. Just make sure that your images don't include any sensitive information.

Submit