forked from WPGov/wp-spid-italia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.php
52 lines (47 loc) · 1.56 KB
/
user.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
add_action('show_user_profile', 'spid_user_profile_fields', 0, 1);
add_action('edit_user_profile', 'spid_user_profile_fields', 0, 1);
add_action('personal_options_update', 'spid_user_profile_fields_update');
add_action('edit_user_profile_update', 'spid_user_profile_fields_update');
function spid_user_profile_fields($user) {
?>
<h3>SPID</h3>
<table class="form-table">
<tr>
<th>
<label for="codice_fiscale">Codice Fiscale</label>
</th>
<td>
<input type="text"
class="regular-text ltr"
id="codice_fiscale"
name="codice_fiscale"
value="<?= esc_attr(get_user_meta($user->ID, 'codice_fiscale', true)); ?>"
pattern="^[a-zA-Z]{6}[0-9]{2}[a-zA-Z][0-9]{2}[a-zA-Z][0-9]{3}[a-zA-Z]$">
</td>
</tr>
<tr>
<th>
<label for="spid_attributes">Attributi SPID</label>
</th>
<td>
<?php print_r( get_user_meta( $user->ID, 'spid_attributes') ); ?>
</td>
</tr>
</table>
<?php
}
/**
* The save action.
*
* @param $user_id int the ID of the current user.
*
* @return bool Meta ID if the key didn't exist, true on successful update, false on failure.
*/
function spid_user_profile_fields_update($user_id) {
if (!current_user_can('edit_user', $user_id)) {
return false;
}
return update_user_meta( $user_id, 'codice_fiscale', $_POST['codice_fiscale'] );
}
?>