Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • vickydev
    Participant

    Right, 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!

    vickydev
    Participant

    Okay 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,
    Vicky

    vickydev
    Participant

    Hello, could someone help me please?

    Many thanks!

    vickydev
    Participant

    Looking forward to your response! Have a great day 🙂

    vickydev
    Participant

    Perfect thank you so much!

    vickydev
    Participant

    Additionally, 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!

Viewing 6 posts - 1 through 6 (of 6 total)
Be inspired. © 2025 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy