Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
demonstrates a simple filter for capturing a dynamic value on the admin side in Participants database
<?php
add_action( 'pdb-form_element_build_text-line', 'xnau_place_dynamic_value' );
/**
* sets the value of a dynamic hidden field in the backend
*
* @param object $field
*/
function xnau_place_dynamic_value( $field )
{
/*
* the field must be a regular pdb field and we must be in the backend
*/
if ( isset( Participants_Db::$fields[$field->name] ) && is_admin() ) {
$default_value = Participants_Db::$fields[$field->name]->default;
/*
* don't change the value if it's already set
* check that it's a dynamic field
*/
if ( empty( $field->value ) && Participants_Db::is_dynamic_value( $default_value ) ) {
$field->value = Participants_Db::get_dynamic_value( $default_value ); // set the value
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment