User field

Shows a dropdown that let you select on of the users of the system.

Return value

Returns the id of the selected user.

If no user is selected an empty string is returned.

Extended Return Values

Note that the value of key user is a WP_User Object which has some magic getter methods, so not all properties are visible when doing a print_r, like below.

Example


$selected_user_id = simple_fields_value('userExample');
$userinfo = get_userdata($selected_user_id);
echo "You selected user with id $selected_user_id";
echo "The username of this user is: " . $userinfo["user_login"];

Output of above


You selected user with id 1.

The username of this user is: admin.

One thought on “User field

  1. Tousif Ahmed

    Hi great plugin!

    I was wondering is there a way to restrict the users to only authors or subscribers.

    It would be great to have this feature!!!!!

Leave a Reply