Last active
April 14, 2022 13:15
-
-
Save ragoand/429fb4d3628993900da8463466fe8307 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
To review the saving process: masterstudy-lms-learning-management-system/lms/classes/user.php, function save_user_info | |
1) Aggiungere tramite filtro i valori che lo script cerca e il loro relativo valore | |
add_filter( 'stm_lms_current_user_data', 'current_user_data' ); | |
function current_user_data($current_user_data) { | |
$current_user_data['billing_vat_number'] = get_user_meta(get_current_user_id(), 'billing_vat_number'); | |
$current_user_data['billing_tax_code'] = get_user_meta(get_current_user_id(), 'billing_tax_code'); | |
return $current_user_data; | |
} | |
2) Aggiungere le chiavi dei campi abilitati al salvataggio. Tutti i campi vegnono salvati nella tabella usermeta | |
add_filter( 'stm_lms_extra_user_fields', 'additional_fields' ); | |
public function additional_fields($additional_fields) { | |
$additional_fields['billing_vat_number'] = [ | |
'label' => esc_html__( 'VAT Number', 'sedweb-masterstudy-addon' ), | |
]; | |
$additional_fields['billing_tax_code'] = [ | |
'label' => esc_html__( 'Tax Number', 'sedweb-masterstudy-addon' ), | |
'required' => true | |
]; | |
return $additional_fields; | |
} | |
3) Override del template stm-lms-templates/account/private/edit_account/name.php . NB i nome dei campi specificati nel v-model devono essere gli stessi indicati al punto 1. | |
Attenzione: lasciare data.meta prima di specificare il nome del nuovo campo. | |
<div class="col-md-6"> | |
<div class="form-group form-group-social"> | |
<label class="heading_font"><?php esc_html_e( 'VAT Number', 'masterstudy-lms-learning-management-system' ); ?></label> | |
<input v-model="data.meta.billing_vat_number" | |
class="form-control" | |
placeholder="<?php esc_html_e( 'VAT Number', 'masterstudy-lms-learning-management-system' ) ?>"/> | |
</div> | |
</div> | |
<div class="col-md-6"> | |
<div class="form-group form-group-social"> | |
<label class="heading_font"><?php esc_html_e( 'Tax Code', 'sedweb-masterstudy-addon' ); ?></label> | |
<input v-model="data.meta.billing_tax_code" | |
class="form-control" | |
placeholder="<?php esc_html_e( 'Tax Code', 'sedweb-masterstudy-addon' ) ?>"/> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment