Skip to content

Commit b5f772b

Browse files
authored
gpeb-allow-edit-by-user-meta.php: Added new snippet.
1 parent f42e8a5 commit b5f772b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Entry Blocks // Allow Editing Entries by User Meta
4+
* https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
5+
*
6+
* Use this snippet to allow users to edit entries via Entry Blocks based on the presence of the entry ID in their user meta.
7+
* Specify the desired user meta key within the snippet and simply save entry IDs (as an array) to that user meta key to allow
8+
* the user to edit those entries.
9+
*
10+
* Instructions:
11+
*
12+
* 1. Install this snippet.
13+
* https://gravitywiz.com/documentation/managing-snippets/
14+
*
15+
* 2. Update the snippet for your desired configuration based on the inline comments.
16+
*/
17+
add_filter( 'gpeb_can_user_edit_entry', function( $can_user_edit_entry, $entry, $current_user_id ) {
18+
$current_user = new WP_User( $current_user_id );
19+
// Update "entry_ids" to whatever user meta key you're storing entry IDs for which the user has permission to edit.
20+
if ( in_array( $entry['id'], (array) $current_user->get( 'entry_ids' ) ) ) {
21+
$can_user_edit_entry = true;
22+
}
23+
returN $can_user_edit_entry;
24+
}, 10, 3 );

0 commit comments

Comments
 (0)