[wp-hackers] User Capabilities

Owen Winkler ringmaster at midnightcircus.com
Mon Jul 11 20:51:07 GMT 2005

David House wrote:
> On 7/11/05, Owen Winkler <ringmaster at midnightcircus.com> wrote:
>>My current implementation of the User Editor page doesn't die() on
>>errors and force the user to use the browser's Back button.  Instead, it
>>redisplays the form with the submitted data, and displays an error
>>message at the top in a .error CSS class similar to the .update class.
>>How do you feel about that?
> That sounds good. That could be something we could implement in more
> places in the core, too.

So far I've been lucky with the way things are built that I can 
rearrange a switch statement and have errors fall through to the next 
case.  I've already implemented this error fall-through on both the 
edit-user page and the users list (for adding new users).  Another nice 
side effect of this is that all errors are reported rather than just the 
first one that calls die().

I also set up the $errors array so that if we wanted to, we could put 
the error messages right near the entry fields.  For example, if there's 
an error with the user_login field (say, a username is already in use), 
then I set:

$errors['user_login'] = __('ERROR: Username already in use');

And so later in the form, you could do:

function form_error_class($field, $errors) {
	echo isset($errors[$field]) ?
	' class="error" title="' . $errors[$field] . '" ' :
<input type="text" name="user_login"
<?php form_error_class('user_login', $errors); ?> />

Or something crazy like that there.

I'm considering adding the oft-asked-for reassignment of posts to a 
different user when a user is deleted.  I'm in there already, right?

I've already modified the options pages to set a default user role for 
new users, and updated the upgrade-schema to use Inactive as the default 
by default.  The default settings on that page are fine, but it's going 
to need a link to Codex if people what to understand what they're changing.

Well, there's not a lot of time left this afternoon and I still have to 
run through my lines for class, so I've attached a new patch that has 
both the caps stuff and the UI stuff that I've completed so far.

The one interface element that doesn't yet work is the Group 
Delete/Reassign Roles section on the user list.  I think everything else 
on the Users tab is working ok.  Try submitting some errors (like 
filling out only one password field) and see if you like the error 
handling.  I'll pick up the ball again tomorrow.

Also be sure to visit the Options | General and Options |Writing pages 
for the changes there regarding new user registrations.  Don't forget to 
  run upgrade.php so that you get the default Role settings.

Lots and lots of small changes in this patch.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: caps_and_UI.diff
Type: text/x-patch
Size: 49471 bytes
Desc: not available
Url : http://comox.textdrive.com/pipermail/wp-hackers/attachments/20050712/6fda9842/caps_and_UI-0001.bin

More information about the wp-hackers mailing list