From d93d8b850d9f3694ef52180f8e453628809ddc4f Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sun, 6 Oct 2013 10:56:09 +0000 Subject: [PATCH] Reverse the order of roles in wp_dropdown_roles(). Reset to 'subscriber' when the default role is removed and when a save is invalid. props garyc40, wonderboymusic. fixes #14578. Built from https://develop.svn.wordpress.org/trunk@25695 git-svn-id: http://core.svn.wordpress.org/trunk@25610 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 2 +- wp-includes/capabilities.php | 3 +++ wp-includes/formatting.php | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index c10402a488..ad42074dcc 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -756,7 +756,7 @@ function wp_dropdown_roles( $selected = false ) { $p = ''; $r = ''; - $editable_roles = get_editable_roles(); + $editable_roles = array_reverse( get_editable_roles() ); foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 789a9dd197..75a834b4f8 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -193,6 +193,9 @@ class WP_Roles { if ( $this->use_db ) update_option( $this->role_key, $this->roles ); + + if ( get_option( 'default_role' ) == $role ) + update_option( 'default_role', 'subscriber' ); } /** diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index e7b752d710..904c99b17b 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -2957,6 +2957,11 @@ function sanitize_option($option, $value) { $value = esc_url_raw( $value ); $value = str_replace( 'http://', '', $value ); break; + + case 'default_role' : + if ( ! get_role( $value ) && get_role( 'subscriber' ) ) + $value = 'subscriber'; + break; } $value = apply_filters("sanitize_option_{$option}", $value, $option);