Advertisements

wp_dropdown_roles

Definition:
function wp_dropdown_roles( $selected = false ) {}

Print out <option> html elements for role selectors

Parameters

  • string $selected: slug for the role that should be already selected

Source code

function wp_dropdown_roles( $selected = false ) {

	$p = '';

	$r = '';



	$editable_roles = get_editable_roles();



	foreach ( $editable_roles as $role => $details ) {

		$name = translate_user_role($details['name'] );

		if ( $selected == $role ) // preselect specified role

			$p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";

		else

			$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";

	}

	echo $p . $r;

}

3617

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: