- Posts: 1
- Thank you received: 0
PHP Script plugin and custom fields.
- Richard Barnes
- Topic Author
- Offline
- New Member
-
Less
More
8 years 3 months ago #99723
by Richard Barnes
PHP Script plugin and custom fields. was created by Richard Barnes
The membership pro PHP Script plugin documentation states.
"In the PHP script, you can use a variable called $row. It contains all information of the subscription record. For example $row->first_name, $row->last_name, $row->email, $row->plan_id...."
Where can I find the available fields that are included in $row and how does it treat custom fields?
R
"In the PHP script, you can use a variable called $row. It contains all information of the subscription record. For example $row->first_name, $row->last_name, $row->email, $row->plan_id...."
Where can I find the available fields that are included in $row and how does it treat custom fields?
R
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
-
8 years 3 months ago #99746
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PHP Script plugin and custom fields.
Hello Richard
1. If you want to see all the fields which you can access via $row object, you will need to look at #__osmembership_subscribers table. $row is basically, a record from that table
2. Unfortunately, right now, we don't have an easy API for accessing to custom fields data. You can try this code to see whether It works
After that code you can acccess to $data to get value of a custom field
Note that I just wrote that code quickly, haven't tested it myself yet
Regards,
Tuan
1. If you want to see all the fields which you can access via $row object, you will need to look at #__osmembership_subscribers table. $row is basically, a record from that table
2. Unfortunately, right now, we don't have an easy API for accessing to custom fields data. You can try this code to see whether It works
Code:
$rowFields = OSMembershipHelper::getProfileFields($row->plan_id);
$data = OSMembershipHelper::getProfileData($rowProfile, $row->plan_id, $rowFields);
After that code you can acccess to $data to get value of a custom field
Note that I just wrote that code quickly, haven't tested it myself yet
Regards,
Tuan
Please Log in or Create an account to join the conversation.
- Joseph Turner
- Offline
- New Member
-
Less
More
- Posts: 11
- Thank you received: 0
5 years 2 days ago - 5 years 2 days ago #137674
by Joseph Turner
Replied by Joseph Turner on topic PHP Script plugin and custom fields.
I am having trouble getting the proposed solution for custom fields to work.
I tried adding a use statement before it like:
I may need to define the namespace hierarchy as part of that statement but I am not sure how.
If that doesn't work is there perhaps another more explicit way of accessing that data?
Thanks,
Joseph
I tried adding a use statement before it like:
Code:
use OSMembershipHelper;
$rowFields = OSMembershipHelper::getProfileFields($row->plan_id);
$data = OSMembershipHelper::getProfileData($rowProfile, $row->plan_id, $rowFields);
I may need to define the namespace hierarchy as part of that statement but I am not sure how.
If that doesn't work is there perhaps another more explicit way of accessing that data?
Thanks,
Joseph
Last edit: 5 years 2 days ago by Joseph Turner.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
-
5 years 2 days ago #137679
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PHP Script plugin and custom fields.
Hello
You should not have to use use OSMembershipHelper;
When you are using my code, exactly what's the error/problem you are having?
Please let me know so that I can understand and find a solution
Tuan
You should not have to use use OSMembershipHelper;
When you are using my code, exactly what's the error/problem you are having?
Please let me know so that I can understand and find a solution
Tuan
Please Log in or Create an account to join the conversation.
- Joseph Turner
- Offline
- New Member
-
Less
More
- Posts: 11
- Thank you received: 0
5 years 1 day ago - 5 years 1 day ago #137722
by Joseph Turner
Replied by Joseph Turner on topic PHP Script plugin and custom fields.
A flash error message populated on the following screen (subscription complete) that said the PHP is wrong and to contact the administrator. I am one of the administrators. The rest of the view was fine.
Before I had successfully triggered an email using the php plugin, but when I try to use your example code to pull a custom field to replace the to address it breaks. I believe the problem is that OSMembershipHelper is out of scope.
Before I had successfully triggered an email using the php plugin, but when I try to use your example code to pull a custom field to replace the to address it breaks. I believe the problem is that OSMembershipHelper is out of scope.
Last edit: 5 years 1 day ago by Joseph Turner.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
-
5 years 1 day ago #137727
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PHP Script plugin and custom fields.
Hello
There was a small typo in the code. Please use this updated code, it should work well:
Regards,
Tuan
There was a small typo in the code. Please use this updated code, it should work well:
Code:
$rowFields = OSMembershipHelper::getProfileFields($row->plan_id);
$data = OSMembershipHelper::getProfileData($row, $row->plan_id, $rowFields);
Regards,
Tuan
Please Log in or Create an account to join the conversation.
- Joseph Turner
- Offline
- New Member
-
Less
More
- Posts: 11
- Thank you received: 0
4 years 11 months ago - 4 years 11 months ago #137767
by Joseph Turner
Replied by Joseph Turner on topic PHP Script plugin and custom fields.
Thanks Tuan,
That was the issue.
It may be worth noting that I had to get the values from the keys using bracket syntax like this:
For some reason I originally expected this to work:
Maybe that will save someone some time in the future.
Best,
Joseph
That was the issue.
It may be worth noting that I had to get the values from the keys using bracket syntax like this:
Code:
$partnerEmail = $data['Contact_Email_1_1'];
For some reason I originally expected this to work:
Code:
$partnerEmail = $data->Contact_Email_1_1;
Maybe that will save someone some time in the future.
Best,
Joseph
Last edit: 4 years 11 months ago by Joseph Turner.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
-
4 years 11 months ago #137770
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PHP Script plugin and custom fields.
Ah, Yes. $data is an array, so Yes, you will have to use bracket syntax to get value of certain custom fields
Tuan
Tuan
Please Log in or Create an account to join the conversation.
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.