- /////Add User Profile item
- add_action( 'show_user_profile', 'sl_profile_fields' );
- add_action( 'edit_user_profile', 'sl_profile_fields' );
- function sl_profile_fields( $user ) {
- ?>
- <h3>社交網絡</h3>
- <table class="form-table">
- <tr>
- <th><label for="weibo">SINA-WEIBO</label></th>
- <td>
- <input type="text" name="weibo" id="weibo" value="<?php echo esc_attr( get_the_author_meta( 'weibo', $user->ID ) ); ?>" /><br />
- <span class="description">新浪微博鏈接</span>
- </td>
- </tr>
- </table>
- <?php
- }
- add_action( 'personal_options_update', 'sl_save_profile_fields' );
- add_action( 'edit_user_profile_update', 'sl_save_profile_fields' );
- function sl_save_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) )
- return false;
- update_user_meta( $user_id, 'weibo', $_POST['weibo'] );
- 用戶打開Wordpress後臺-->用戶-->我的資料的時候,會在“更新個人資料“按鈕上方出現新增的微博設置項
WP如何爲用戶添加資料選項
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.