Retrieving Custom Profile Field Values

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
xgarb
Registered User
Posts: 20
Joined: Thu Jan 24, 2008 4:31 pm

Retrieving Custom Profile Field Values

Post by xgarb » Mon Aug 22, 2016 6:01 pm

I want to include the custom profile field values in the email sent to admin.

I've got the following code but $profile_fields only includes the standard profile fields. Can I include custom fields somehow?

Code: Select all

public function get_email_template_variables()
	{
	$board_url = generate_board_url();
	$username = $this->user_loader->get_username($this->item_id, 'username');

	global $phpbb_container;
	$cp = $phpbb_container->get('profilefields.manager');
	$profile_fields = $cp->grab_profile_fields_data($this->item_id);

	return array(
		'USERNAME'			=> htmlspecialchars_decode($username),
		'FULL_NAME'			=> htmlspecialchars_decode($profile_fields['pf_full_name']),
		'U_USER_DETAILS'	=> "{$board_url}/memberlist.{$this->php_ext}?mode=viewprofile&u={$this->item_id}",
		'U_ACTIVATE'		=> "{$board_url}/ucp.{$this->php_ext}?mode=activate&u={$this->item_id}&k={$this->get_data('user_actkey')}",
		);
	}
Last edited by Mick on Mon Aug 22, 2016 6:06 pm, edited 1 time in total.

xgarb
Registered User
Posts: 20
Joined: Thu Jan 24, 2008 4:31 pm

Re: Retrieving Custom Profile Field Values

Post by xgarb » Fri Nov 11, 2016 10:23 am

I just noticed this topic got moved to Extension Writers but it's about the 3.1 core custom profile fields. Can someone move it back please.

User avatar
JimA
Community Team Leader
Community Team Leader
Posts: 7651
Joined: Thu Jul 31, 2008 5:54 am
Location: The Netherlands
Name: Jim Mossing Holsteyn
Contact:

Re: Retrieving Custom Profile Field Values

Post by JimA » Fri Nov 11, 2016 2:04 pm

xgarb wrote:I just noticed this topic got moved to Extension Writers but it's about the 3.1 core custom profile fields. Can someone move it back please.
Your question might be about core custom profile fields, but you're using custom code to get their values.

Therefore you'd be more likely to get a response in Extensions Writers Discussion as that where the people with coding experience usually answer questions. These days the support forums are mostly used for basic questions about the operation of the core phpBB package.
Image Jim Mossing Holsteyn - Community Team Leader
Knowledge Base | Documentation | Board rules

If you're having any questions about the rules/customs of this website, feel free to drop me a PM.

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3897
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Retrieving Custom Profile Field Values

Post by kasimi » Fri Nov 11, 2016 8:34 pm

The grab_profile_fields_data() method does return custom profile fields but the data it returns is different than what you expect.

Give this a try: $profile_fields[$this->item_id]['pf_full_name']['value']

xgarb
Registered User
Posts: 20
Joined: Thu Jan 24, 2008 4:31 pm

Re: Retrieving Custom Profile Field Values

Post by xgarb » Mon Nov 14, 2016 12:09 pm

Code: Select all

'FULL_NAME' => htmlspecialchars_decode($profile_fields[$this->item_id]['full_name']['value']),
is working nicely for me. Thanks!

stefan-franz
Registered User
Posts: 76
Joined: Mon Mar 11, 2019 7:29 pm

Re: Retrieving Custom Profile Field Values

Post by stefan-franz » Fri Mar 29, 2019 6:12 pm

kasimi wrote:
Fri Nov 11, 2016 8:34 pm
The grab_profile_fields_data() method does return custom profile fields but the data it returns is different than what you expect.

Give this a try: $profile_fields[$this->item_id]['pf_full_name']['value']
Hallo, i found this topic.....but i don't know why/what do do.....

My problem: I like to send after register a e-mail to admin (admin_activate.txt) with the custom profile field called "sponsor_name"

How can i do it? in what files do i have add the feature?

Lg Stefan


User avatar
david63
Registered User
Posts: 16535
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Retrieving Custom Profile Field Values

Post by david63 » Sun Mar 31, 2019 7:22 am

ViolaF wrote:
Sun Mar 31, 2019 2:38 am
viewtopic.php?f=72&t=1769475#p10995855
That topic is for phpBB 3.0 - the way is which CPFs are handled changed in phpBB 3.1 therefore I doubt that it will work
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
3Di
Former Team Member
Posts: 14220
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Retrieving Custom Profile Field Values

Post by 3Di » Sun Mar 31, 2019 9:39 am

Not that all of this belongs to this forum IMO :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

User avatar
Mick
Support Team Member
Support Team Member
Posts: 21564
Joined: Fri Aug 29, 2008 9:49 am
Location: Caerdydd

Re: Retrieving Custom Profile Field Values

Post by Mick » Sun Mar 31, 2019 11:52 am

3Di wrote:
Sun Mar 31, 2019 9:39 am
Not that all of this belongs to this forum IMO
Indeed.
stefan-franz wrote:
Fri Mar 29, 2019 6:12 pm
How can i do it?
This topic is solved so you should start a new topic in phpBB Custom Coding which has been added for this type of request since this topic was started. You can link back to this topic if you wish.
"The more connected we get the more alone we become" - Kyle Broflovski

Post Reply

Return to “Extension Writers Discussion”