Skip to content

Instantly share code, notes, and snippets.

@hzlzh
Created March 5, 2013 06:05
Show Gist options
  • Select an option

  • Save hzlzh/5088360 to your computer and use it in GitHub Desktop.

Select an option

Save hzlzh/5088360 to your computer and use it in GitHub Desktop.
Custom user profile page's options.
<?php
add_filter('user_contactmethods','my_user_contactmethods');
function my_user_contactmethods($user_contactmethods ){
unset($user_contactmethods['aim']);
unset($user_contactmethods['yim']);
unset($user_contactmethods['jabber']);
unset($user_contactmethods['googleplus']);
$user_contactmethods ['company'] = '公司';
$user_contactmethods ['position'] = '职位';
$user_contactmethods ['weibo'] = '微博地址 <span class="description">(http://)</span>';
return $user_contactmethods ;
}
// remove personal options block
if(is_admin()){
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
add_action( 'personal_options', 'prefix_hide_personal_options' );
}
function prefix_hide_personal_options() {
?>
<script type="text/javascript">
jQuery(document).ready(function( $ ){
$("#first_name, #last_name, #url").parent().parent().remove();
$("h3")[3].remove();
$("label[for='nickname']").html('姓名 <span class="description">(必填)</span>')
$("label[for='description']").html('个人简介')
});
</script>
<?php
}
function mod_backend_new_user_fields() { ?>
<script type="text/javascript">
// Remove selected fields only
var hideFields = [ "first_name", "last_name", "url" ];
jQuery.each( jQuery( "tr.form-field" ), function() {
var field = jQuery( this ).find( "input" ).attr( "id" );
if ( hideFields.indexOf( field ) != -1 ) {
jQuery( this ).remove();
}
});
</script>
<?php }
add_action( 'admin_footer-user-new.php', 'mod_backend_new_user_fields' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment