Skip to content

Instantly share code, notes, and snippets.

@xnau
Last active October 11, 2025 19:23
Show Gist options
  • Select an option

  • Save xnau/aeab03582a9b2610fa963487ddb48c82 to your computer and use it in GitHub Desktop.

Select an option

Save xnau/aeab03582a9b2610fa963487ddb48c82 to your computer and use it in GitHub Desktop.
Shows how to unapprove a Participants Database record when it is edited on the frontend
<?php
/**
*
* Plugin Name: Unapprove Record on Frontend Edit
* Description: When a record is edited by a frontend user, switch the approval to "no"
*
*/
/*
* set it up so that our function will be triggered when a record is updated
*/
add_action( 'pdb-after_submit_update', 'xnau_unapprove_edited_record');
/**
* switches the approval field to "no" when a record is edited on the frontend
*
* @param array $record
*/
function xnau_unapprove_edited_record( $record )
{
// don't do anything if the edit is taking place on the backend
if ( is_admin() )
{
return;
}
// get the name of the approval field
$approval_field_name = 'approved';
// the value of the approval field when it is not approved
$unapproved = 'no';
// get the id of the record from the data
$record_id = $record['id'];
// update the record with the unapproved value
Participants_Db::write_participant( [$approval_field_name => $unapproved], $record_id );
}
@xnau
Copy link
Author

xnau commented Oct 11, 2025

This is installed as a plugin: How to Install a WordPress Plugin from a Gist

Check the plugin code to make sure the approval field name and unapprove value are correct for your site.

Note that if you want to approve a record, you will have to do this on the backend.

This plugin does not check to see if anything was changed, that is more complicated because it will need to check on the database before the update happens, and this plugin runs after the update has completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment