Skip to content

Instantly share code, notes, and snippets.

@xnau
Created October 14, 2017 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xnau/a8754b6cd5bb724a03780ab7885fd736 to your computer and use it in GitHub Desktop.
Save xnau/a8754b6cd5bb724a03780ab7885fd736 to your computer and use it in GitHub Desktop.
shows how to use the "approved" field in a Participants Database record to prevent a record from being edited
<?php
// if the record is not approved, they cannot edit the record.
// you can easily adapt this to any other checkbox field so you can use that field to prevent editing
add_filter( 'pdb-check_submission', function() {
if ( !is_admin() && $_POST['action'] === 'update' ) {
$record = Participants_Db::get_participant( $_POST['id']);
// if the field has a value of "yes" allow editing
// if it is any other value, editing will not be allowed
return $record['approved'] === 'yes';
}
return true;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment