Retrieving CPF Fields

Post

Posted
Rating:
#4827 (In Topic #1057)
Avatar
Standard member
supertramp4 is in the usergroup ‘Well-settled’
Hi,
Can someone give me some advise on how ( in php) would you return a specific CPF field for a member.

ie $_username = $GLOBALS['CNS_DRIVER']->get_member_row_field($member_id, 'm_username');
returns the Username

if I had a CPF called "ScreenName" how would i get that using the $member_id.


The end goal ( if im feeling brave) is to try and modify the forum system to display the CPF "ScreenName", rather than the username. Its only the displayed text i want to change rather than any underlying links or the functionality

This is both for security to prevent people who use their e-mail address as their user name from it obviously being displayed, and convienience as some usernames are not always clear to the user.

As a fall back if the CPF is null/blank, then i would aim to continue to display the username.
Thanks
Chris
Online now: No Back to the top

Post

Posted
Rating:
#4829
Avatar
Site staff
Adam is in the usergroup ‘Super-moderators’
Not to answer your question directly, but there is already a 'Display name generator' feature which you can tie to a existing CPF and will likely do what you want here. Admin Zone → Setup → Configuration → User/usergroup options
Online now: No Back to the top

Post

Posted
Rating:
#4830
Avatar
Standard member
supertramp4 is in the usergroup ‘Well-settled’
Wow, that's cool - Thanks

I missed that config option completely. I'll give it a go

Chris
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#4831
Avatar
Standard member
supertramp4 is in the usergroup ‘Well-settled’
Thanks Kingbast.

Works a treat.
Online now: No Back to the top

Post

Posted
Rating:
#4832
Avatar
Site staff
Adam is in the usergroup ‘Super-moderators’
Glad to hear it ;)
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#4833
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
For reference, I think $GLOBALS['CNS_DRIVER']->get_member_row_field($member_id, 'field_10'); works, where 10 is the field ID. There are a few ways for reading in CPFs for members.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

deepu_ms, Vaiva, amit.nigam, Manu, ManojSree, mytracker, gabriel58, babu, Paul D

Forum statistics:
  • 1,296 topics, 5,829 posts, 7,064 members
  • Our newest member is flour2door
Birthdays:
Back to Top