[SOLVED] How add a property in portal_memberdata dinamically

Hello,

I want add property user to (portal_memberdata) using code and not update day by day. it's would be auto-add so dinamically.

I read on the Plone Docs:

New properties must be explicitly declared in portal_memberdata

There's any way to find it out?

Thanks

I use generic setup to setup the memberdata properties. Two Files are available, but i'm not sure if it necessary that both are manipulate. memberdata.xml and memberdata_properties.xml. you can export these files via portal_setup.

I know how edit and add fields by that way. But this won't be a "dinamically" solution.

Perhaps:

portal_memberdata = getToolByName(site, "portal_memberdata")
if not portal_memberdata.hasProperty("home_folder_uid"):
    portal_memberdata.manage_addProperty(id="home_folder_uid", value="", type="string")

2 Likes

thank you wou save me.. I not understand how you wanna said before!

Hi, where can I add this ? I'm not a python dev but just started learning for plone.

Can you explain what you want to add, there are a few things to consider.

  1. It is possible to 'just add a property
  2. It is possible to let the user edit this (his/her) property
  3. About edit: it is possible to let the user add it when register, or just when editing profile or both, or you can have a setting which only an admin can edit.

Some of this can be done TTW (in the browser), but others require 'some kind of programming'.

Hey, thanks for replying. I'm just wondering if I can add a property home_folder_uid on portal_memberdata and assign value programatically.

Saw this python code somewhere at http://localhost:8080/Plone/@@actions-controlpanel when editing My Folder action which can be used to assign the value

portal.portal_membership.getHomeFolder()

python:(member is not None) and (portal.portal_membership.getHomeFolder() is not None)

It is possible to add properties without an add on, try: yoursite/@@member-fields

If you have your own add on, it is easy to add with plonecli (ask here and I will answer)):

in /profiles/default you add a file memberdata_properties.xml (or memberdata.xml, I do not remember which is which).
In this file you add your property.
When you install your add-on, this property will be available.

The easies way to know 'how this file should look' is to go to yoursite//portal_setup/manage_exportSteps

and export the settings.

Then you 'just add your field to that memberdata.xml (or memeberdata_properties.xml)

Remember: you need to install the add-on to 'get the setting'