Updating Plone Portal email address

Hi,

We are using Plone 4.3.3 along with Plomino database. Our Plone site is configured to use email address as the username for login.

I am unfortunately unable to find a way to update the email address programmatically when a logged-in user changes their email address inside the plomino application.

There is only a addMember method with portal_registration tool but is there an updateMember method for portal_membership?

Thanks
Ash

You can use the setProperty method for that:

user = context.getCurrentMember()
user.setProperty('email', 'my@email.com')

@ebrehault - thank you and sorry about the delay.

setProperty is throwing an attribute error unfortunately. The code I'm using

UpdatedEmail = plominoDocument.getItem('EmailUpdate')

if not plominoDocument.getItem('Email') == UpdatedEmail:
   context.getCurrentMember().setProperty('email',UpdatedEmail)

Tried plominoContext with no luck. Any ideas why it is failing?

did you tried with a regular user account or with 'admin'? (admin might produce errors)

Thanks @ebrehault I tried as a regular user without admin permissions.

sorry, I made a mistake in my answer: setProperty does not exist, we must use setProperties, so try:
context.getCurrentMember().setProperties(email=UpdatedEmail)

1 Like

@ebrehault Thanks for your help.

I have corrected the formula but now the the form is misbehaving by giving the same Attribute error: setProperty even when I have completely remove the code. I was using it in onOpen Event of a form and now whenever I fill in the updated email, it comes up with AttributeError.

Ideally should be some kind of cache but I am not certain why it is not clearing. Happens with old plomino documents or new ones. Have tried to recompute documents, refresh database, restart all instances (including zeo) and still getting the AttributeError when there is no related code in the form.

Any clues?

@ebrehault - don't worry about the cached error, I just reimported the database design from live DB and things are OK now.

I tested your code and works perfectly. One major thing I forgot to mention is that we use email address for login and I realised that the UserID in acl_users (ZMI) are not updated by just updating the setProperties (quite obvious because I am not updating it)

Do you know how I'll be able to update the UserID and Login name in acl_users (ZMI)?

Thanks much

@ebrehault, I think I managed to figure out a way to update Login name.

There was a method in CMFPlone Utils updateOwnLoginName which was helpful with updating the login name easily.

So I think I have solved this mystery in-effect.

Thanks again for all the help. :slight_smile: