---
title: "Letting a role edit and delete other users&#8217; entries in one View"
date: 2026-10-26
updated: 2026-10-26
author: "Rafael Bennemann"
link: "https://www.gravitykit.com/docs/gravityview/edit-entry/role-edit-delete-entries-one-view/"
category: "GravityView > Edit Entry"
---

GravityView lets a user edit an entry on the front end when they created it and the View allows it, or when their role may edit every entry on the site ([How does GravityView know who can edit the entry?](https://www.gravitykit.com/docs/gravityview/edit-entry/how-does-gravityview-know-who-can-edit-the-entry/)). Some sites need something in between, such as a facilities manager who edits and deletes the requests other people submitted, in one View, without access to the Gravity Forms **Entries** screen or to other Views. A short code snippet gives one role that access.

The capabilities in [Creating an Entry Moderator role](https://www.gravitykit.com/docs/gravityview/edit-entry/how-to-allow-a-user-to-edit-all-entries/) work on every View and form on the site, so use them when the role should edit everything.

## Before you start

- Add a **Link to Edit Entry** field to the View's **Multiple Entries** or **Single Entry** layout. To let the role delete entries too, add a **Delete Entry** field.
- Note the View's ID. It's the number in the **Embed Shortcode** in the **Publish** box of the View editor, such as `123` in `[gravityview id="123"]`.
- Note the role's slug, the name WordPress uses for the role in code, such as `author` for the Author role.

## Add the snippet

Replace `123` with your View's ID and `facilities_manager` with your role's slug.

```
/**
 * Lets one role edit and delete every entry that one View shows them.
 *
 * @param bool       $allowed Whether the current user can edit (or delete) the entry.
 * @param array      $entry   The Gravity Forms entry.
 * @param int|string $view_id The ID of the View the link belongs to.
 *
 * @return bool
 */
$gk_view_role_access = function ( $allowed, $entry, $view_id ) {

    $allowed_view_id = 123;                  // The ID of your View.
    $allowed_role    = 'facilities_manager'; // The slug of your role.

    // Leave other Views and other users as they are.
    if ( (int) $view_id !== $allowed_view_id || ! in_array( $allowed_role, (array) wp_get_current_user()->roles, true ) ) {
        return $allowed;
    }

    // Allow only the entries this View shows the user.
    $view = \GV\View::by_id( $view_id );

    if ( ! $view || is_wp_error( GVCommon::check_entry_display( $entry, $view ) ) ) {
        return $allowed;
    }

    return true;
};

add_filter( 'gravityview/edit_entry/user_can_edit_entry', $gk_view_role_access, 10, 3 );
add_filter( 'gk/gravityview/delete-entry/can-delete', $gk_view_role_access, 10, 3 );
```

**Note**: [Adding custom PHP code snippets to your website](https://www.gravitykit.com/docs/gravityview/customizing-your-views/where-to-put-code-samples/) explains where to put this code.

To let the role edit without deleting, remove the last line.

## What the role can do

Signed in with the role, a user sees the **Edit Entry** and **Delete Entry** links on every entry the View shows them, and can edit and delete those entries. The View's **Allow User Edit** and **Allow User Delete** settings can stay off, because they only cover the entries a user created. If the View has GravityEdit's **Enable Inline Edit** turned on, the role can also edit the View's entries in place.

![A Table View of maintenance requests seen by a user with the facilities role, with Edit Entry and Delete Entry links on every request](https://www.gravitykit.com/wp-content/uploads/2026/10/gravityview-edit-delete-links-one-role.png)
*Other roles keep their usual permissions, and in other Views the role has no more rights than before*
The check against the View keeps editing and deleting to the entries the View lists for that user. An Edit link to any other entry of the form shows "You do not have permission to edit this entry." A Delete link shows "There was an error deleting the entry: You do not have permission to delete this entry." and the entry stays.

## When an edit removes the entry from the View

If an edit changes a value the View filters on, the entry leaves the View. For example, a View that hides requests with the status Done no longer shows a request once its status is set to Done. GravityView saves the change, and the **Edit Entry** screen then shows "You do not have permission to edit this entry." in place of the confirmation, because the entry is no longer in the View. The View's page shows the updated list.

## Deleting entries

Deleting an entry through the View removes it for good. To move deleted entries to the trash, where an administrator can restore them, use the filter in [Change the Delete Entry mode from "Delete" to "Trash"](https://www.gravitykit.com/docs/gravityview/advanced/change-the-delete-entry-mode-from-delete-to-trash/).

The two filters in the snippet are documented on the developer site: [`gravityview/edit_entry/user_can_edit_entry`](https://www.gravitykit.dev/docs/gravityview/filters/gravityview-edit_entry-user_can_edit_entry/) and [`gk/gravityview/delete-entry/can-delete`](https://www.gravitykit.dev/docs/gravityview/filters/gk-gravityview-delete-entry-can-delete/).