• After a good bit of digging I figured out how to modify the ‘edit-user.php’ page in the admin area such that it now has the additional information I want for users and no longer shows information that I am not interested in, but I cannot seem to find any way to modify the ‘user-new.php’ page to match.

    In the case of the edit-user.php changes, I was able to add functions that used the add_action( 'show_user_profile', 'value' ) hook to add new items to the page, and a combination of unset() and some jQuery to remove some of the fields.

    So far I have not been able to find anything similar that I could use to modify the ‘user-new.php’ page to achieve similar results. Does anyone know how this can be achieved outside of making changes to the core?

    TIA,

    Jay

Viewing 4 replies - 1 through 4 (of 4 total)
  • The way I would do this is using jQuery. Add some JS code in the page using ‘admin_head-{hook-suffix}’ action hook and implement what you need.

    Thread Starter jaydrake

    (@jaydrake)

    Is there a hook for that page? I haven’t been able to find it. If I simply add/subtract form elements to the page how will WP know to store the added form elements and not concern itself with the elements that were removed?

    It this what you need?

    // Add Twitter profile field and remove Yahoo IM
    function add_twitter_contactmethod( $contactmethods ) {
    	// Add Twitter
    	$contactmethods['twitter'] = 'Twitter';
    
    	// Remove Yahoo IM
    	unset($contactmethods['yim']);
    
    	return $contactmethods;
    }
    add_filter('user_contactmethods','add_twitter_contactmethod',10,1);

    Here’s how I remove certain fields from the “Add New User” page:

    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' );

    But I have yet to find out how to add custom fields and save them once submitted in the “Add New User” page…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Modify 'Users > Add New' Page’ is closed to new replies.