Programatically Access Custom Fields

  • Joshua Vines
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #97930 by Joshua Vines
Programatically Access Custom Fields was created by Joshua Vines
I am creating a custom view to override the default registrant list. The plan is to show a list of registered exhibitors and their details. How do I access specific custom field data?

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #97958 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Programatically Access Custom Fields
Hello

If you look at the original file, you will see this

$fieldValue = $this->fieldValues[$row->id][$fieldId];

That's the code to access to a custom field value. Note $row->id is id of the registrant, $fieldId is id of the custom field

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Joshua Vines
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #98040 by Joshua Vines
Replied by Joshua Vines on topic Programatically Access Custom Fields
How do I find the $fieldId? I know the field name, not the field id.

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #98047 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Programatically Access Custom Fields
Go to Events Booking -> Custom Fields, you will see ID of each field at the most right column. For example, first_name field has ID = 1, last_name field has ID = 2....

Tuan

Please Log in or Create an account to join the conversation.

  • Joshua Vines
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #98059 by Joshua Vines
Replied by Joshua Vines on topic Programatically Access Custom Fields
This implies knowing the field name/id pairs in advance. I would like to be able to use the field *name* in the code, like I can with the core fields. This would make debugging easier, among other benefits.

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #98061 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Programatically Access Custom Fields
The core fields are stored in one table, so it is easy to have it works like that, for none core fields, it is difficult. For now, please use the field ID. I hear you and will add support for access via field name in the next release of the extension

Regards,

Tuan

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc