Last active
January 22, 2020 20:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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