Skip to content

Instantly share code, notes, and snippets.

@ideadude
Last active January 22, 2020 20:33
Show Gist options
  • Save ideadude/37fc272e688811efa5a408fd9e75f37e to your computer and use it in GitHub Desktop.
Save ideadude/37fc272e688811efa5a408fd9e75f37e to your computer and use it in GitHub Desktop.
Update PMPro Register Helper fields after they've been setup, e.g. to add them to the Add Member screen.
/**
* Update RH fields after they've been setup.
* The example below sets the addmember property to true.
* Add this code to a custom plugin or Code Snippet.
*/
function my_update_rh_fields() {
global $pmprorh_registration_fields;
if ( empty( $pmprorh_registration_fields ) ) {
return;
}
// add field names to look for
$fields_to_update = array( 'company', 'budget' );
foreach( $pmprorh_registration_fields as $locations => $fields ) {
foreach( $fields as $field ) {
if( in_array( $field->name, $fields_to_update ) ) {
// updates to be made to the field
$field->addmember = true;
}
}
}
}
add_action( 'init', 'my_update_rh_fields', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment