• I have added an additional title field to the user profile, and have added this to the admin page using the approach defined here.

    This all works perfectly, but I’d really like to be able to place the field for the title data above the first name and last name fields within user-edit.php, rather than right at the end. I could do this by editing user-edit.php directly, but clearly that’s not ideal. Is there any way to define a custom version of user-edit.php within my theme and redirect a call to that page to use the theme rather than core file?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    The only way I can think of is change the page with javascript. I’ve made an example of an added profile field called title here: http://pastebin.com/ESYe3evt

    You have to create a file called my_profile_script.js and put the javascript in there. Put this file in a folder called js in your theme folder (wp-content/themes/yourtheme/js/my_profile_script.js)

    Thread Starter batters22

    (@batters22)

    Thanks keesiemeijer, hadn’t instantly thought of using js to manipulate the form. I’m sure that would work. Interested in any alternative approaches as well.

    Moderator keesiemeijer

    (@keesiemeijer)

    The form in user-edit.php is hard coded and has no filter hooks available to change the output of the form itself. Redirecting to your own (maybe plugin) profile page could of course also work.

    Thread Starter batters22

    (@batters22)

    OK, I’ve got as far as making this work via a redirect, with a custom file located in the wp-admin folder using this:

    function vcongress_redirect_user_edit() {
    	global $pagenow;
    	if ( 'user-edit.php' === $pagenow ) {
    		$user_id = $_GET['user_id'];
    		$referrer = $_GET['wp_http_referer'];
    		wp_redirect( 'vcongress-user-edit.php?user_id=' . $user_id . '&wp_http_referer=' . $referrer );
    	}
    }
    
    if ( is_admin() )  add_action( 'admin_menu', 'vcongress_redirect_user_edit' );

    Can’t currently get this to work with my custom file located in the theme folder. The redirect works OK but then even with the path within user-edit.php changed to reference wp-admin/admin.php I end up being prompted for reauth. Any suggestions on how to address this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add field to user-edit.php’ is closed to new replies.