Skip to content

Instantly share code, notes, and snippets.

@MarkLimmage
Forked from JudeRosario/1-instructions.txt
Last active January 8, 2017 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkLimmage/f3b4a89a97783be5ff053f8fb7671ac7 to your computer and use it in GitHub Desktop.
Save MarkLimmage/f3b4a89a97783be5ff053f8fb7671ac7 to your computer and use it in GitHub Desktop.
Add custom field in M2 registration form (Basic) WPMU Membership2
### We are adding telephone number as custom field
1. Go to /wp-content/plugins/membership/app/view/templates/ and copy all 4 files.
2. Go to /wp-content/themes/YOUR_CURRENT_THEME/ and create a new folder called membership2, then paste all 4 files inside the new created membership2 folder
3. Open membership_registration_form.php and put the following: membership_registration_form.php
4. Now open the membership_account.php file and put the following: membership_account.php
5. Finally need to add some code: mu-plugin.php
## You can add those codes in your functions.php in the theme,
## if you think your theme won’t be changed. Otherwise mu-plugins is the best solution.
## To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'.
## If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that,
## give any name you like and paste the code in there. You don't need to activate that plugin.
## Mu-plugins means must use plugins, so it will be activated automatically always.
## If you use mu-plugins then add a php start tag at the beginning of the code.
<div style="text-align:center">
<div style="display:inline-block;">
<img src="https://maxicheapit.com.au/sarah/wp-content/uploads/sites/2/2016/12/logo-blue.png">
<h1>Well being for your whole being</h1><br><br>
<div style="text-align:left;"<ul>
<li>Our Classes are open to all as a Beginners/Intermediate General level yoga classes. Please advise the teacher of any injury, illness or health condition you have bef$
</li><li>Please do not try to do poses that don’t feel right for your body - seek guidance from the teacher for an alternative posture that will ultimately bring you gre$
</li><li>It is ideal if you come to class with an empty stomach, bowel and bladder. Therefore please don&#39;t eat for at least 2 hours before a session. If you really n$
</li></ul><br><br>Please complete the information below and be assured that the information provided will only be used by Centenary Yoga</div>
</div>
</div>
<?php
echo get_ms_registration_form_fields();
echo '<div class="ms-extra-fields">';
/**
* Trigger default WordPress action to allow other plugins
* to add custom fields to the registration form.
*
* signup_extra_fields Defined in wp-signup.php which is used
* for Multisite signup process.
*
* register_form Defined in wp-login.php which is only used for
* Single site registration process.
*
* @since 1.0.0
*/
ms_registration_form_extra_fields();
?>
<!-- Adding extra fields here -->
<div class="ms-form-element ms-form-element-telephone">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="telephone" class="wpmui-field-label wpmui-label-telephone ">Telephone </label>
<input class="wpmui-field-input wpmui-text wpmui-input-telephone" type="text" id="telephone" name="telephone" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-dob">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="dob" class="wpmui-field-label wpmui-label-dob ">Date of Birth </label>
<input class="wpmui-field-input wpmui-date wpmui-input-dob" type="date" id="dob" name="dob" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-address">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="address" class="wpmui-field-label wpmui-label-address ">Address </label>
<input class="wpmui-field-input wpmui-text wpmui-input-address" type="text" id="address" name="address" value="">
</span>
</div>
<div class="ms-form-element wpmui-field-label">
<span class="wpmui-wrapper wpmui-input-wrapper"><label class="wpmui-field-label">Health Concerns</label><br>Please check any of the boxes below that apply.</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="injury" class="wpmui-field-label wpmui-label-injury ">Injury </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-injury" type="checkbox" id="injury" name="injury" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="osteoporosis" class="wpmui-field-label wpmui-label-osteoporosis ">Osteoporosis </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-osteoporosis" type="checkbox" id="osteoporosis" name="osteoporosis" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="bloodpressure" class="wpmui-field-label wpmui-label-bloodpressure ">High or low blood pressure </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-bloodpressure" type="checkbox" id="bloodpressure" name="bloodpressure" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="stress" class="wpmui-field-label wpmui-label-stress ">Stress or Anxiety </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-stress" type="checkbox" id="stress" name="stress" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="pregnant" class="wpmui-field-label wpmui-label-pregnant ">Pregnant </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-pregnant" type="checkbox" id="pregnant" name="pregnant" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="fatigue" class="wpmui-field-label wpmui-label-fatigue ">Fatigue </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-fatigue" type="checkbox" id="fatigue" name="fatigue" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="heartlung" class="wpmui-field-label wpmui-label-heartlung ">Heart and Lung Concerns </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-heartlung" type="checkbox" id="heartlung" name="heartlung" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="back" class="wpmui-field-label wpmui-label-back ">Back Issues </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-back" type="checkbox" id="back" name="back" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="diabetes" class="wpmui-field-label wpmui-label-diabetes ">Diabetes </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-diabetes" type="checkbox" id="diabetes" name="diabetes" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="epilepsy" class="wpmui-field-label wpmui-label-epilepsy ">Epilepsy </label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-epilepsy" type="checkbox" id="epilepsy" name="epilepsy" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-health">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="visualhearing" class="wpmui-field-label wpmui-label-visualhearing ">Visual Hearing Impaired</label>
<input class="wpmui-field-input wpmui-checkbox wpmui-input-visualhearing" type="checkbox" id="visualhearing" name="visualhearing" value="">
</span>
</div>
<div class="ms-form-element ms-form-element-address">
<span class="wpmui-wrapper wpmui-input-wrapper ">
<label for="other" class="wpmui-field-label wpmui-label-other ">Other Health Concerns </label>
<input class="wpmui-field-input wpmui-text wpmui-input-address" type="text" id="other" name="other" value="">
</span>
</div>
<div class="ms-form-element wpmui-field-label">
<span class="wpmui-wrapper wpmui-input-wrapper"><label class="wpmui-field-label">Indemnity</label><br><br>
All due care is taken in the instruction of these classes and only poses deemed safe for the student will be taught. Please be aware however, that each student is respon$
<br><br>By registering you acknowledge that you have read and understood these instructions and take full responsibility for yourself in class.</span></div><br><br>
<!-- Adding extra fields here/End -->
<?php
echo '</div>';
echo get_ms_registration_form_register_button();
ms_registration_form_error();
/**
* This hook is intended to output hidden fields or JS code
* at the end of the form tag.
*
* @since 1.0.1.0
*/
do_action( 'ms_shortcode_register_form_end', ms_registration_form_obj() );
?>
<br><br>
<?php
if ( is_ms_registration_form_login_link_exists() ) {
echo get_ms_registration_form_login_link();
}
<div class="ms-account-wrapper">
<?php if ( ms_is_user_logged_in() ) : ?>
<?php
// ================================================= MEMBERSHIPS
if ( ms_is_user_logged_in() ) : ?>
<div id="account-membership">
<h2>
<?php
echo get_ms_ac_title();
if ( show_membership_change_link() ) {
echo get_ms_ac_signup_modified_url();
}
?>
</h2>
<?php
/**
* Add custom content right before the memberships list.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_memberships_top', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
if ( is_ms_admin_user() ) {
_e( 'You are an admin user and have access to all memberships', 'membership2' );
} else {
if ( has_ms_ac_subscriptions() ) {
?>
<table>
<tr>
<th class="ms-col-membership"><?php
_e( 'Membership name', 'membership2' );
?></th>
<th class="ms-col-status"><?php
_e( 'Status', 'membership2' );
?></th>
<th class="ms-col-expire-date"><?php
_e( 'Expire date', 'membership2' );
?></th>
</tr>
<?php
$empty = true;
$m2_subscriptions = get_ms_ac_subscriptions();
foreach ( $m2_subscriptions as $subscription ) :
$empty = false;
ms_account_the_membership( $subscription );
?>
<tr class="<?php echo get_ms_account_classes(); ?>">
<td class="ms-col-membership"><?php echo get_ms_account_membership_name(); ?></td>
<td class="ms-col-status"><?php echo get_ms_account_membership_status(); ?></td>
<td class="ms-col-expire-date"><?php echo get_ms_account_expire_date(); ?></td>
</tr>
<?php
endforeach;
if ( $empty ) {
echo get_ms_no_account_membership_status();
}
?>
</table>
<?php
} else {
_e( 'No memberships', 'membership2' );
}
}
/**
* Add custom content right after the memberships list.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_memberships_bottom', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
?>
</div>
<?php
endif;
?>
<?php
// ===================================================== PROFILE
if ( is_ms_ac_show_profile() ) : ?>
<div id="account-profile">
<h2>
<?php
echo get_ms_ac_profile_title();
if ( is_ms_ac_show_profile_change() ) {
echo get_ms_ac_profile_change_link();
}
?>
</h2>
<?php
/**
* Add custom content right before the profile overview.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_profile_top', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
?>
<table>
<?php $profile_fields = get_ms_ac_profile_fields(); ?>
<?php foreach ( $profile_fields as $field => $title ) : ?>
<tr>
<th class="ms-label-title"><?php echo esc_html( $title ); ?>: </th>
<td class="ms-label-field"><?php echo esc_html( get_ms_ac_profile_info( $field ) ); ?></td>
</tr>
<?php endforeach; ?>
<tr>
<th class="ms-label-phone">Telephone: </th>
<td class="ms-label-field"><?php echo esc_html( get_user_meta( get_current_user_id(), 'ms_telephone', true ) ); ?></td>
</tr>
<tr>
<th class="ms-label-phone">Date of Birth: </th>
<td class="ms-label-field"><?php echo esc_html( get_user_meta( get_current_user_id(), 'ms_dob', true ) ); ?></td>
</tr>
<tr>
<th class="ms-label-phone">Address: </th>
<td class="ms-label-field"><?php echo esc_html( get_user_meta( get_current_user_id(), 'ms_address', true ) ); ?></td>
</tr>
<tr>
<th class="ms-label-phone">Health Concerns: </th>
<td class="ms-label-field"><?php echo esc_html( get_user_meta( get_current_user_id(), 'ms_other', true ) ); ?></td>
</tr>
</table>
<?php
do_action( 'ms_view_account_profile_before_card', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
do_action( 'ms_view_shortcode_account_card_info', get_ms_ac_data() );
/**
* Add custom content right after the profile overview.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_profile_bottom', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
?>
</div>
<?php
endif;
// END: if ( $show_profile )
// =============================================================
?>
<?php
// ==================================================== INVOICES
if ( is_ms_ac_show_invoices() ) : ?>
<div id="account-invoices">
<h2>
<?php
echo get_ms_ac_invoices_title();
if ( is_ms_ac_show_all_invoices() ) {
echo get_ms_ac_invoices_detail_label();
}
?>
</h2>
<?php
/**
* Add custom content right before the invoice overview list.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_invoices_top', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
?>
<table>
<thead>
<tr>
<th class="ms-col-invoice-no"><?php
_e( 'Invoice #', 'membership2' );
?></th>
<th class="ms-col-invoice-status"><?php
_e( 'Status', 'membership2' );
?></th>
<th class="ms-col-invoice-total"><?php
printf(
'%s (%s)',
__( 'Total', 'membership2' ),
MS_Plugin::instance()->settings->currency
);
?></th>
<th class="ms-col-invoice-title"><?php
_e( 'Membership', 'membership2' );
?></th>
<th class="ms-col-invoice-due"><?php
_e( 'Due date', 'membership2' );
?></th>
</tr>
</thead>
<tbody>
<?php $m2_invoices = get_ms_ac_invoices(); ?>
<?php foreach ( $m2_invoices as $invoice ) :
ms_account_the_invoice( $invoice );
?>
<tr class="<?php echo get_ms_invoice_classes(); ?>">
<td class="ms-col-invoice-no"><?php echo get_ms_invoice_number(); ?></td>
<td class="ms-col-invoice-status"><?php echo get_ms_invoice_next_status(); ?></td>
<td class="ms-col-invoice-total"><?php echo get_ms_invoice_total(); ?></td>
<td class="ms-col-invoice-title"><?php echo get_ms_invoice_name(); ?></td>
<td class="ms-col-invoice-due"><?php echo get_ms_invoice_due_date(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
/**
* Add custom content right after the invoices overview list.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_invoices_bottom', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
?>
</div>
<?php
endif;
?>
<?php
// ==================================================== ACTIVITY
if ( is_ms_ac_show_activity() ) : ?>
<div id="account-activity">
<h2>
<?php
echo get_ms_ac_activity_title();
if ( is_ms_ac_show_all_activities() ) {
echo get_ms_ac_activity_details_label();
}
?>
</h2>
<?php
/**
* Add custom content right before the activities overview list.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_activity_top', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
?>
<table>
<thead>
<tr>
<th class="ms-col-activity-date"><?php
_e( 'Date', 'membership2' );
?></th>
<th class="ms-col-activity-title"><?php
_e( 'Activity', 'membership2' );
?></th>
</tr>
</thead>
<tbody>
<?php $m2_events = get_ms_ac_events(); ?>
<?php foreach ( $m2_events as $event ) :
ms_account_the_event( $event );
?>
<tr class="<?php echo get_ms_event_classes(); ?>">
<td class="ms-col-activity-date"><?php echo get_ms_event_date(); ?></td>
<td class="ms-col-activity-title"><?php echo get_ms_event_description(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
/**
* Add custom content right after the activities overview list.
*
* @since 1.0.0
*/
do_action( 'ms_view_account_activity_bottom', get_ms_ac_member_obj(), get_ms_ac_account_obj() );
?>
</div>
<?php
endif;
?>
<?php else :
if ( ! has_ms_ac_login_form() ) {
echo get_ms_ac_login_form();
}
endif; ?>
</div>
<?php
/**
* Saving custom field values
*/
add_action( 'ms_model_member_create_new_user', function( $user ) {
update_user_meta( $user->id, 'ms_telephone', $_POST['telephone'] );
update_user_meta( $user->id, 'ms_dob', $_POST['dob'] );
update_user_meta( $user->id, 'ms_address', $_POST['address'] );
update_user_meta( $user->id, 'ms_injury', $_POST['injury'] );
update_user_meta( $user->id, 'ms_osteoporosis', $_POST['osteoporosis'] );
update_user_meta( $user->id, 'ms_stress', $_POST['stress'] );
update_user_meta( $user->id, 'ms_pregnant', $_POST['pregnant'] );
update_user_meta( $user->id, 'ms_fatigue', $_POST['fatigue'] );
update_user_meta( $user->id, 'ms_heartlung', $_POST['heartlung'] );
update_user_meta( $user->id, 'ms_back', $_POST['back'] );
update_user_meta( $user->id, 'ms_diabetes', $_POST['diabetes'] );
update_user_meta( $user->id, 'ms_visualhearing', $_POST['visualhearing'] );
update_user_meta( $user->id, 'ms_other', $_POST['other'] );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment