1

What I want to do:

I want to change the profile (backend) layout. Hide and add personal fields.

What I don't want to do:

Use some dirty javascript hacks to remove fields


Adding fields is actually not a problem. I already wrote a plugin for this.
But now I want to hide some default wordpress fields. I've researched a bit into this topic. It seems there are exactly 2 options to hide fields. Either edit user-edit.php or use JS/jQuery to remove fields.

So.. What about editing user-edit.php and just replace/edit the file again after wordpress updates? Doesn't sound that wrong. I guess it's not that critical. What do you think? Or is there even a better way to handle this?

2

What about just targeting with CSS?

tr.user-nickname-wrap { display: none; }

Of course the fields will still be in the source but the CSS targeting will be faster than JS.

You can load your WP Admin CSS this way:

function wse_183286_profile_admin_css() {
    $screen_id = isset( get_current_screen()->id ) ? get_current_screen()->id : null;

    if ( 'profile' === $screen_id || 'user-edit' === $screen_id ) {
        wp_enqueue_style( 'profile-admin-css', '/path/to/your/file.css' );
    }
}
add_action( 'admin_enqueue_scripts', 'wse_183286_profile_admin_css' );

Unfortunately, I don't think there are hooks provided in WordPress (yet) to remove fields in the clean way you are looking for.

  • Still feels dirty, no? Kinda too hacky imho. I feel pretty good with my custom profile page tbh. Well anyway. Didn't even consider the css way, which is obviously way better than CSS. Thank you – Brettetete Apr 5 '15 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.