Skip to content

Instantly share code, notes, and snippets.

@fumikito
Created October 22, 2010 15:40
Show Gist options
  • Save fumikito/640783 to your computer and use it in GitHub Desktop.
Save fumikito/640783 to your computer and use it in GitHub Desktop.
WordPressのプロフィール編集画面でコンタクトフィールドをカスタマイズする
/**
* Customize contact fields on Profile admin panel
*
* @package WordPress
*/
/**
* WordPressのプロフィール画面に追加するコンタクトメソッド
*
* @var array
*/
$original_contactmethods = array(
"twitter" => "Twitter",
"facebook" => "Facebook"
);
/**
* デフォルトのコンタクトフィールドを削除する
*
* @param array $contactmethods
* @return array
* @author WP Beginners
* @url http://www.wpbeginner.com/wp-tutorials/how-to-remove-default-author-profile-fields-in-wordpress/
*/
function hide_profile_fields( $contactmethods ) {
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
unset($contactmethods['yim']);
return $contactmethods;
}
add_filter('user_contactmethods','hide_profile_fields',10,1);
/**
* デフォルトのプロフィール編集画面に新しいコンタクトフィールドを追加する
*
* @param array $contactmethods
* @return array
* @author WP Beginners
* @url http://www.wpbeginner.com/wp-tutorials/how-to-display-authors-twitter-and-facebook-on-the-profile-page/
*/
function original_profile_fields( $contactmethods ) {
global $original_contactmethods;
foreach($original_contactmethods as $key => $val)
$contactmethods[$key] = $val;
return $contactmethods;
}
add_filter('user_contactmethods','original_profile_fields',11,1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment