Forum Replies Created
- AuthorPosts
- July 7, 2023 at 6:29 pm in reply to: Allow specific roles to view specific forms and their entries #35721
vickydev
ParticipantRight, this is quite helpful, I wrote this but it’s not working however I do think im very close, would you be able to help me correct what’s wrong?
function restrict_quform_entry_access($allcaps, $cap, $args) {
// Check if the capability being checked is related to Quform entry access
if ($cap === ‘quform_view_entries’) {
// Get the form ID from the entry ID
$repository = quform(‘repository’);
$form_id = $repository->getFormIdFromEntryId((int) $_GET[‘id’]);// Define the form IDs you want to restrict access to
$restricted_form_ids = array(“1″,”2″,”4”); // Replace with your desired form IDs// Define the user roles that are forbidden to access the forms
$forbidden_roles = array(‘editor, author’); // Replace with your desired roles// Get the current user’s role
$user = wp_get_current_user();
$user_roles = $user->roles;// Check if the user has any forbidden roles and if the form ID matches any restricted form ID
if (in_array($form_id, $restricted_form_ids) && array_intersect($user_roles, $forbidden_roles)) {
// Deny access to the specific form entry
$allcaps[$cap] = false;
}
}return $allcaps;
}
add_filter(‘user_has_cap’, ‘restrict_quform_entry_access’, 10, 3);Many thanks in advance!
July 4, 2023 at 1:08 pm in reply to: Allow specific roles to view specific forms and their entries #35705vickydev
ParticipantOkay thank you very much, I will try to write something myself to see if I can manage it with a code snippet for now.. any pointers as to what hook to use to get a formID and the user role would be much appreciated!
Many thanks,
VickyJuly 3, 2023 at 3:59 pm in reply to: Allow specific roles to view specific forms and their entries #35698vickydev
ParticipantHello, could someone help me please?
Many thanks!
June 30, 2023 at 11:45 am in reply to: Allow specific roles to view specific forms and their entries #35696vickydev
ParticipantLooking forward to your response! Have a great day 🙂
March 24, 2022 at 7:24 pm in reply to: Form notification recipient being the emails from a specific user role #34115vickydev
ParticipantPerfect thank you so much!
March 23, 2022 at 11:09 am in reply to: Form notification recipient being the emails from a specific user role #34111vickydev
ParticipantAdditionally, when I do try to add an email address, it doesnt allow emails that end with @nhs.net . Is there a way to bypass that validation?
Many thanks!
- AuthorPosts