Accessing custom memberdata

3 messages Options
Embed this post
Permalink
audleman () Accessing custom memberdata
Reply Threaded More More options
Print post
Permalink
Hello all,

I have added a few properties to my memberdata, namely "organization" and "region." I am trying to update the author.cpt template (e.g. what you see when you click on a users name anywhere in the site) to display these new fields but have run into a stumbling block. This template calls the function mtool.getMemberInfo to bring in member properties but it doesn't include any custom. Indeed, I checked out the documentation for the function in MembershipTool.py and the function politely tells me

"""
Return 'harmless' Memberinfo of any member, such as Full name, Location, etc.
"""

So how do I gain access to my additional properties?

The author.cpt template has the following defined:

mtool - I assume this means membership tool
author - A string with the author name

I would think I should try to get the member object then call member.getProperty for each of my properties. However I don't know how to get the member object.

Any help greatly appreciated.

Thanks,
Kevin
Raphael Ritz () Re: Accessing custom memberdata
Reply Threaded More More options
Print post
Permalink
audleman wrote:

> Hello all,
>
> I have added a few properties to my memberdata, namely "organization" and
> "region." I am trying to update the author.cpt template (e.g. what you see
> when you click on a users name anywhere in the site) to display these new
> fields but have run into a stumbling block. This template calls the function
> mtool.getMemberInfo to bring in member properties but it doesn't include any
> custom. Indeed, I checked out the documentation for the function in
> MembershipTool.py and the function politely tells me
>
> """
> Return 'harmless' Memberinfo of any member, such as Full name, Location,
> etc.
> """
>
> So how do I gain access to my additional properties?
>
> The author.cpt template has the following defined:
>
> mtool - I assume this means membership tool
> author - A string with the author name
>
> I would think I should try to get the member object then call
> member.getProperty for each of my properties. However I don't know how to
> get the member object.
>

context.portal_membership.getMemberById(<some member id string>)

note, however, that this returns the fully decorated member
object including potentially sensitive info. Therefore, this
call is protected by the 'Manage portal' permission.

Alternatively, you can patch the 'getMemberInfo' method to include
your custom properties.
Or you write a custom method in trusted code (file system) based
on the above.

HTH

        Raphael

BTW: stuff like that isn't exactly setup/installation related and
could also be asked on 'plone-users' where more people would see it.



> Any help greatly appreciated.
>
> Thanks,
> Kevin


_______________________________________________
Setup mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/setup
audleman () Re: [Setup] Accessing custom memberdata
Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Raphael,

Cheers, this solved my problem. Actually, I discovered that the variable "member" was already set, so all I had to do was use it.

I'll post questions like this to plone-users next time, thanks for letting me know where to post.

Thanks,
Kevin

Raphael Ritz (via Nabble) wrote:
audleman wrote:

> Hello all,
>
> I have added a few properties to my memberdata, namely "organization" and
> "region." I am trying to update the author.cpt template (e.g. what you see
> when you click on a users name anywhere in the site) to display these new
> fields but have run into a stumbling block. This template calls the function
> mtool.getMemberInfo to bring in member properties but it doesn't include any
> custom. Indeed, I checked out the documentation for the function in
> MembershipTool.py and the function politely tells me
>
> """
> Return 'harmless' Memberinfo of any member, such as Full name, Location,
> etc.
> """
>
> So how do I gain access to my additional properties?
>
> The author.cpt template has the following defined:
>
> mtool - I assume this means membership tool
> author - A string with the author name
>
> I would think I should try to get the member object then call
> member.getProperty for each of my properties. However I don't know how to
> get the member object.
>

context.portal_membership.getMemberById(<some member id string>)

note, however, that this returns the fully decorated member
object including potentially sensitive info. Therefore, this
call is protected by the 'Manage portal' permission.

Alternatively, you can patch the 'getMemberInfo' method to include
your custom properties.
Or you write a custom method in trusted code (file system) based
on the above.

HTH

        Raphael

BTW: stuff like that isn't exactly setup/installation related and
could also be asked on 'plone-users' where more people would see it.



> Any help greatly appreciated.
>
> Thanks,
> Kevin


_______________________________________________
Setup mailing list
Setup@...
http://lists.plone.org/mailman/listinfo/setup