
Käyttäjäprofiiliin osoitetietojen lisäys
By:
samikeijonen on
Jan 25th, 2012 | syntax:
PHP | size: 1.49 KB | hits: 68 | expires: Never
<?php
/* Lisää käyttäjän sivulle osoitetiedot. http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields.
* Huom! Funktio update_usermeta on vanhentunut, käytä funktiota update_user_meta.
*/
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
/* Osoitetiedot käyttäjät-sivulle */
function my_show_extra_profile_fields( $user ) {
?>
<h3>Osoitetiedot</h3>
<table class="form-table">
<tr>
<th><label for="osoite">Osoite</label></th>
<td>
<input type="text" name="osoite" id="osoite" value="<?php echo esc_attr( get_user_meta( $user->ID, 'osoite', true ) ) ; ?>" class="regular-text" /><br />
<span class="description">Osoite.</span>
</td>
</tr>
<tr>
<th><label for="postinumero">Postinumero</label></th>
<td>
<input type="text" name="postinumero" id="postinumero" value="<?php echo esc_attr( get_user_meta( $user->ID, 'postinumero', true ) ) ; ?>" class="regular-text" /><br />
<span class="description">Postinumero.</span>
</td>
</tr>
<tr>
<th><label for="postitoimipaikka">Postitoimipaikka</label></th>
<td>
<input type="text" name="postitoimipaikka" id="postitoimipaikka" value="<?php echo esc_attr( get_user_meta( $user->ID, 'postitoimipaikka', true ) ) ; ?>" class="regular-text" /><br />
<span class="description">Postitoimipaikka.</span>
</td>
</tr>
</table>
<?php }