{"id":7,"date":"2007-10-04T13:56:00","date_gmt":"2007-10-04T18:56:00","guid":{"rendered":"http:\/\/blogs.devhorizon.com\/reza\/?p=7"},"modified":"2007-11-21T11:17:35","modified_gmt":"2007-11-21T16:17:35","slug":"getting-user-login-from-the-peopleeditor-via-code","status":"publish","type":"post","link":"https:\/\/blogs.devhorizon.com\/reza\/2007\/10\/04\/getting-user-login-from-the-peopleeditor-via-code\/","title":{"rendered":"Getting user login from the PeopleEditor via Code"},"content":{"rendered":"<p>Assuming you have a people editor control defined like below:<\/p>\n<p> &lt;wssawc:PeopleEditor AllowEmpty=&#8221;false&#8221;\u00a0 ID=&#8221;myPeopleEditorControl&#8221; runat=server SelectionSet=&#8221;<strong>User<\/strong>&#8221; MaximumEntities=&#8221;1&#8243; MultiSelect=&#8221;<strong>false<\/strong>&#8221; AllowTypeIn=&#8221;false&#8221; Width=&#8217;500px&#8217; \/&gt;<\/p>\n<p> The following code sample will get you the currently logged on user&#8217;s login from the PeopleEditor control:<\/p>\n<p> \u00a0 ArrayList peEntities = myPeopleEditorControl.Entities;<br \/>\n \u00a0 PickerEntity pickEn = (PickerEntity)peEntities[0];<br \/>\n \u00a0 stringLogIn = pickEn.Key;<\/p>\n<p> This comes handy when you want to create an SPUser context out of the entities kept in the PeopleEditor control. For example:<\/p>\n<p> \u00a0private SPUser GetUser(string logIn)<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/>\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SPUser user = this.workflowProperties.Web.SiteUsers[logIn];<br \/>\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return user;<br \/>\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> Don&#8217;t forget Required Field Validation on your people editor control if you want the code not to break on you.<\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" width=\"1\" src=\"\/\/blogs.devhorizon.com\/aggbug.aspx?PostID=510\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Assuming you have a people editor control defined like below: &lt;wssawc:PeopleEditor AllowEmpty=&#8221;false&#8221;\u00a0 ID=&#8221;myPeopleEditorControl&#8221; runat=server SelectionSet=&#8221;User&#8221; MaximumEntities=&#8221;1&#8243; MultiSelect=&#8221;false&#8221; AllowTypeIn=&#8221;false&#8221; Width=&#8217;500px&#8217; \/&gt; The following code sample will get you the currently logged on user&#8217;s login from the PeopleEditor control: \u00a0 ArrayList peEntities = myPeopleEditorControl.Entities; \u00a0 PickerEntity pickEn = (PickerEntity)peEntities[0]; \u00a0 stringLogIn = pickEn.Key; This comes handy when [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[3],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-moss-2007","tag-moss-2007"],"_links":{"self":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":0,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}