Opened 13 months ago

Last modified 11 months ago

#20563 new enhancement

Add actions between sections in User Edit form

Reported by: sc0ttkclark Owned by:
Priority: normal Milestone: Awaiting Review
Component: Plugins Version: 3.4
Severity: normal Keywords: needs-patch
Cc:

Description

Currently there is only one hookable area in the User Edit to cleanly output additional fields: 'edit_user_profile' / 'show_user_profile'

I suggest we add another set just before each of the H3 tags on this page (/wp-admin/user-edit.php).

Above Personal Options:

<?php
	if ( IS_PROFILE_PAGE )
		do_action( 'show_user_profile_personal', $profileuser );
	else
		do_action( 'edit_user_profile_personal', $profileuser );
?>
<h3><?php _e('Personal Options'); ?></h3>

Above Name:

<?php
	if ( IS_PROFILE_PAGE )
		do_action( 'show_user_profile_name', $profileuser );
	else
		do_action( 'edit_user_profile_name', $profileuser );
?>
<h3><?php _e('Name') ?></h3>

Above Contact Info:

<?php
	if ( IS_PROFILE_PAGE )
		do_action( 'show_user_profile_contact', $profileuser );
	else
		do_action( 'edit_user_profile_contact', $profileuser );
?>
<h3><?php _e('Contact Info') ?></h3>

Above About:

<?php
	if ( IS_PROFILE_PAGE )
		do_action( 'show_user_profile_about', $profileuser );
	else
		do_action( 'edit_user_profile_about', $profileuser );
?>
<h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>

For hooking into the save, I believe the existing action 'user_profile_update_errors' will suffice, though I'm not sure if that's the best name for having developers hook into for adding their own field and this runs after error checking.. So we could also add an action before error checking runs to allow for more extensibility to modify existing fields being saved there (letting you still use WP built-in error handling).

This would be added around line 130 in /wp-admin/includes/user.php:

	// Allow plugins to modify user fields before error handling
	do_action_ref_array( 'user_profile_update', array ( &$user, $update ) );

	$errors = new WP_Error();

Change History (5)

Also, I'm aware personal options has it's own hook, but it's only for within the table or after the table specifically only on the profile (self) page.

The general solution here would be to use the Settings API on this screen.

@scribu - I entirely agree here, as long as also there remains some action that runs below each section, so that plugins can add their own sections within the page.

@scribu - There's ticket #13548 which is a request for the Settings API on this screen, this current ticket could still be separate, or it's needs could be taken into consideration under #13548 buildout.

Note: See TracTickets for help on using tickets.