Code
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 | |
function add_user_post_form( $bool ) { | |
global $profileuser; | |
if ( preg_match( '/^(profile\.php|user-edit\.php)/', basename( $_SERVER['REQUEST_URI'] ) ) ) { | |
?> | |
<tr> | |
<th scope="row">住所</th> | |
<td> | |
<input type="text" name="user_post" id="user_post" value="<?php echo esc_html( $profileuser->user_post ); ?>" /> | |
</td> | |
</tr> | |
<?php | |
} | |
return $bool; | |
} | |
add_action( 'show_password_fields', 'add_user_post_form' ); | |
function update_user_post( $user_id, $old_user_data ) { | |
if ( isset( $_POST['user_post'] ) && $old_user_data->user_post != $_POST['user_post'] ) { | |
$user_post = sanitize_text_field( $_POST['user_post'] ); | |
$user_post = wp_filter_kses( $user_post ); | |
$user_post = _wp_specialchars( $user_post ); | |
update_user_meta( $user_id, 'user_post', $user_post ); | |
} | |
} | |
add_action( 'profile_update', 'update_user_post', 10, 2 ); | |
?> |
Screen shot
Note
Description | プロフィールの「あなたについて」の部分に項目を増やす |
---|---|
WordPress Ver. | 3.3.1 |
Via | WordPressのユーザー管理画面カスタマイズまとめ |