Skip to content

Instantly share code, notes, and snippets.

@bennemann
bennemann / gravity-view-claim-entry-by-user-data.php
Last active October 19, 2026 13:34
GravityView: let a user edit an entry they did not create, when a field in the entry names them
<?php
/**
* Let a signed-in user edit an entry they did not create, when a field in the entry names them.
*
* GravityView lets a user edit the entries they created, or every entry through a capability that holds across the
* whole site. This adds a narrower way for the Views you list: a user may edit an entry when one of its fields (a
* "Teacher", an "Agent", a "Manager") holds their user ID, or a value from their user meta. It applies to the Edit
* Entry screen and to GravityEdit's inline editing.
*
* Match on something users cannot change themselves: their user ID, or a user meta key that only an administrator
@bennemann
bennemann / gravity-view-claim-entry-by-email.php
Created March 20, 2020 22:16
Modify whether the currently logged-in user can edit an entry that was not created by him
<?php
add_filter('gravityview/edit_entry/user_can_edit_entry', 'gv_claim_entry_by_email', 20, 3 );
/**
* Modify whether the currently logged-in user can edit an entry that was not created by him
*
* @param boolean $user_can_edit Can the current user edit the current entry? (Default: false)
* @param array $entry Gravity Forms entry array
* @param int $view_id ID of the view you want to check visibility against {@since 1.15}
*
@bennemann
bennemann / gravity-view-hide-closed-days.php
Last active March 22, 2020 22:10
Hide closed days for selected view on Gravity Forms Business Hours plugin by GravityView
<?php
add_filter('gravityforms_business_hours_output_closed_template', 'gv_dont_show_closed_days', 10, 3 );
/**
* Hides business hours for closed days on selected view.
*
* @param string $output_template HTML code
* @param string $day Day of the week value
* @param array $replacements Default values to replace with *
*