Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bryanwillis/b986722a50f897d7d0f1b131c29f9de5 to your computer and use it in GitHub Desktop.
Save bryanwillis/b986722a50f897d7d0f1b131c29f9de5 to your computer and use it in GitHub Desktop.
Code to add measurement and formula history
<?php
/** Studio T Formula History and Measurement History **/
function bw_custom_user_profile_fields( $user ) {
echo '<h3 class="heading">Salon Customer Data</h3>';
?>
<table class="form-table">
<tr>
<th><label for="_sln_bformula">Formula History</label></th>
<td>
<input type="textarea" name="_sln_bformula" id="_sln_bformula" value="<?php echo esc_attr( get_the_author_meta( '_sln_bformula', $user->ID ) ); ?>" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<table class="form-table">
<tr>
<th><label for="_sln_bmeasure">Measurements History</label></th>
<td>
<input type="textarea" name="_sln_bmeasure" id="_sln_bmeasure" value="<?php echo esc_attr( get_the_author_meta( '_sln_bmeasure', $user->ID ) ); ?>" rows="5" cols="30"></textarea>
</td>
</tr>
</table>
<?php
}
add_action( 'show_user_profile', 'bw_custom_user_profile_fields' );
add_action( 'edit_user_profile', 'bw_custom_user_profile_fields' );
function bw_save_custom_user_profile_fields( $user_id ) {
if ( current_user_can( 'edit_posts', $user_id ) ) {
update_user_meta( $user_id, '_sln_bformula', sanitize_text_field( $_POST['_sln_bformula'] ) );
update_user_meta( $user_id, '_sln_bmeasure', sanitize_text_field( $_POST['_sln_bmeasure'] ) );
}
}
add_action( 'personal_options_update', 'bw_save_custom_user_profile_fields' );
add_action( 'edit_user_profile_update', 'bw_save_custom_user_profile_fields' );
function bw_salon_book_add_customer_meta($customer) {
?>
<div class="col-xs-12 col-md-6 form-group sln_meta_field sln-input--simple">
<label for="_sln_customer_sln_bformula">Formula History</label>
<textarea placeholder="Enter formula here..." type="text" name="sln_customer_meta[_sln_bformula]" id="_sln_customer_sln_bformula" class="form-control" rows="5"><?php echo $customer->get('_sln_bformula'); ?></textarea>
</div>
<div class="col-xs-12 col-md-6 form-group sln_meta_field sln-input--simple">
<label for="_sln_customer_sln_bmeasure">Measurements History</label>
<textarea placeholder="Enter measurements here..." type="text" name="sln_customer_meta[_sln_bmeasure]" id="_sln_customer_sln_bmeasure" class="form-control" rows="5"><?php echo $customer->get('_sln_bmeasure'); ?></textarea>
</div>
<?php
}
add_action('sln.template.customer.metabox', 'bw_salon_book_add_customer_meta');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment