Tweaking your user profile page in WordPress

The following functions will help you when tweaking your user page. Use them in the functions.php of your theme:

<?php
add_action( 'admin_head', 'user_profile_remove_color_scheme');
add_action( 'personal_options', 'sfn_personal_options');
add_action( 'show_user_profile', 'sfn_user_profile' );
add_action( 'edit_user_profile', 'sfn_user_profile' );
add_action( 'user_contactmethods', 'sfn_user_contactmethods');
//hooks for user registration and deletion
add_action( 'user_register', 'sfn_user_register');
add_action( 'delete_user', 'sfn_delete_user');

function user_profile_remove_color_scheme() {
   global $_wp_admin_css_colors;
   $_wp_admin_css_colors = 0;
}

function sfn_personal_options() {
    ?>
    <script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery("#your-profile .form-table:first, #your-profile h3:first").remove();
        jQuery("#your-profile #url").parent().parent().remove();
        jQuery("#your-profile #description").parent().parent().remove();
    });
    </script>
    <?php
}

function sfn_user_profile(){
    $userinfo = get_userdata($_GET['user_id']);
    //add something here to show after password fields.
}

function sfn_user_contactmethods($cm){
    unset($cm["aim"]);
    unset($cm["yim"]);
    unset($cm["jabber"]);
    return $cm;
}

function sfn_user_register($userid){
  $userinfo = get_userdata($userid);
  //do something after user registration
}

function sfn_delete_user($userid){
  $userinfo = get_userdata($userid);
  //do something after user deletion
}

Leave a Reply