Skip to content

Commit

Permalink
gpnf-disable-sessions.php: Fixed an issue where non-admin users are…
Browse files Browse the repository at this point in the history
… not able to edit or delete entries.
  • Loading branch information
barthc committed Aug 21, 2024
1 parent 60b2c19 commit e516ddf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gp-nested-forms/gpnf-disable-sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,17 @@
function gw_gpnf_disable_session() {
remove_action( 'wp_ajax_gpnf_session', array( gp_nested_forms(), 'ajax_session' ) );
remove_action( 'wp_ajax_nopriv_gpnf_session', array( gp_nested_forms(), 'ajax_session' ) );
// Delete previous stored session.
$session = new GPNF_Session( '4' ); // Update "4" to the ID of the parent form.
$session->delete_cookie();
}

// Allow non-admin users to edit or delete entry.
add_filter( 'gpnf_can_user_edit_entry', function( $can_user_edit_entry, $entry ) {
// Update "5" to the ID of the child form.
if ( $entry['form_id'] == '5' ) {
return true;
}

return $can_user_edit_entry;
}, 10 , 2);

Check failure on line 33 in gp-nested-forms/gpnf-disable-sessions.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Space found before comma in argument list

0 comments on commit e516ddf

Please sign in to comment.