Skip to content

Instantly share code, notes, and snippets.

@zkovalenko
Created March 8, 2021 15:55
Show Gist options
  • Save zkovalenko/4516cc6a5efde0766fa012edfca54235 to your computer and use it in GitHub Desktop.
Save zkovalenko/4516cc6a5efde0766fa012edfca54235 to your computer and use it in GitHub Desktop.
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
// Define the fields.
$fields = array();
$fields[] = new PMProRH_Field(
'machineId', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Machine Id', // custom field label
'size' => 30, // input size
'class' => 'company', // custom class
'profile' => true, // show in user profile
'required' => false, // make this field required
)
);
// Add the fields into a new pmprorh_registration_fields
foreach ( $fields as $field ) {
pmprorh_add_registration_field(
'pmprorh_registration_fields', // location on checkout page
$field // PMProRH_Field object
);
}
function my_pmpro_add_memberslist_col_machineId( $columns ) {
$columns['machineId'] = 'Machine Id';
return $columns;
}
add_filter( 'pmpro_manage_memberslist_columns', 'my_pmpro_add_memberslist_col_machineId' );
function my_pmpro_fill_memberslist_col_machineId( $colname, $user_id ) {
if ( 'machineId' === $colname ) {
echo esc_html( get_user_meta( $user_id, 'machineId', true ) );
}
}
add_filter( 'pmpro_manage_memberslist_custom_column', 'my_pmpro_fill_memberslist_col_machineId', 10, 2 );
}
add_action( 'init', 'my_pmprorh_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment