You are here: Home / Documentation / How To's / How to fetch a user ID by email address

How to fetch a user ID by email address

by nguyen — published Jun 05, 2009 04:36 PM, last modified Aug 16, 2016 10:50 AM
contributed by Andrew Schultz
studentSupervisor = obj.portal_membership.searchMembers('email', obj.getSupervisorEmail())
supervisorUserName = "%(username)s" % studentSupervisor[0] 

when you use the searchMembers method, it defaults the username and email (as dictionary objects) as a return.

so for your second line, all you have to do is:

 

"%(username or email goes here)s" % yourvariable[at index] 

 


to return the email or username without the dictionary markup.

Alternatively:

(studentSupervisorUserName, studentSupervisorEmail) = obj.portal_membership.searchMembers('email', obj.getSupervisorEmail())


One line only, plus no string interpolation (faster).

Navigation