- Posts: 76
- Thank you received: 0
Creating online form with fields filled up with membership details
- bumble
- Topic Author
- Offline
- Senior Member
Less
More
3 years 8 months ago #137101
by bumble
Replied by bumble on topic Creating online form with fields filled up with membership details
Hi Tuan, I am unable to pull the information from a custom field. It is not in the #__osmembership_subscribers table. Where can I find it? How should I code it?
Guessing it has something to do with field id from #__osmembership_field_value table? Correct me if I'm wrong! Waiting for your reply. Thank you!
Guessing it has something to do with field id from #__osmembership_field_value table? Correct me if I'm wrong! Waiting for your reply. Thank you!
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
3 years 8 months ago #137102
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Creating online form with fields filled up with membership details
You're right that you will have to query data directly from #__osmembership_field_value table
Tuan
Tuan
Please Log in or Create an account to join the conversation.
- bumble
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 76
- Thank you received: 0
3 years 8 months ago #137103
by bumble
Replied by bumble on topic Creating online form with fields filled up with membership details
Ok so I now have to pull a custom field from another table:
#__osmembership_field_value table
The fields have field IDs and not names.
Can you advise how I should add this to the existing code?
Thank you.
#__osmembership_field_value table
The fields have field IDs and not names.
Can you advise how I should add this to the existing code?
Thank you.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
3 years 8 months ago #137105
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Creating online form with fields filled up with membership details
What code you are using to get data now?
Please Log in or Create an account to join the conversation.
- bumble
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 76
- Thank you received: 0
3 years 8 months ago #137106
by bumble
Replied by bumble on topic Creating online form with fields filled up with membership details
Here is the code:
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDbo();
$db->setQuery("Select * From #__osmembership_subscribers Where user_id = " . $db->quote(JFactory::getUser()->get('id')));
$subscriber = $db->loadObject();
ff_setValue('last_name', $subscriber->last_name);
ff_setValue('first_name', $subscriber->first_name);
ff_setValue('membership_id', $subscriber->membership_id);
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDbo();
$db->setQuery("Select * From #__osmembership_subscribers Where user_id = " . $db->quote(JFactory::getUser()->get('id')));
$subscriber = $db->loadObject();
ff_setValue('last_name', $subscriber->last_name);
ff_setValue('first_name', $subscriber->first_name);
ff_setValue('membership_id', $subscriber->membership_id);
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
3 years 8 months ago #137107
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Creating online form with fields filled up with membership details
Try this code:
Try that code. it allows you to get value of custom field with name test_field_1, test_field_2. Hope you get the logic and can make it works as you want
Tuan
Code:
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.name, b.field_value')
->from('#__osmembership_fields AS a')
->innerJoin('#__osmembership_field_value AS b ON a.id = b.field_id')
->where('b.subscriber_id = ' . $subscriber->id);
$db->setQuery($query);
$fieldValues = $db->loadObjectList('name');
if (isset($fieldValues['test_field_1']))
{
$testField1Value = $fieldValues['test_field_1']->field_value;
}
else
{
$testField1Value = '';
}
if (isset($fieldValues['test_field_2']))
{
$testField2Value = $fieldValues['test_field_2']->field_value;
}
else
{
$testField2Value = '';
}
Try that code. it allows you to get value of custom field with name test_field_1, test_field_2. Hope you get the logic and can make it works as you want
Tuan
Please Log in or Create an account to join the conversation.
- bumble
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 76
- Thank you received: 0
3 years 8 months ago #137125
by bumble
Replied by bumble on topic Creating online form with fields filled up with membership details
Hi Tuan,
Can't seem to get it to work.
Do we need to reference #__osmembership_fields table to get the name of the field?
Or is "test_field_1" is field ID?
Can't seem to get it to work.
Do we need to reference #__osmembership_fields table to get the name of the field?
Or is "test_field_1" is field ID?
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
3 years 8 months ago #137148
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Creating online form with fields filled up with membership details
test_field_1, test_field_2 is name of the custom field. Could you paste the actual code you are using so that I can look at it to see what's wrong?
Tuan
Tuan
Please Log in or Create an account to join the conversation.
- bumble
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 76
- Thank you received: 0
3 years 8 months ago #137170
by bumble
Replied by bumble on topic Creating online form with fields filled up with membership details
I wish to display these 4 fields in a Crosstec BreezingForms fields:
1. First Name: "first_name"
2. Last Name: "last_name"
3. Membership ID: "membership_id"
4. Identification Number: "idnumber"
The first 3 fields load fine with the original code.
Having problems with the 4th field as it is a custom field and must be pulled from other tables.
How do I combine the previous code with the new code?
When I add the code below the form does not load & page only displays the word Error.
1. First Name: "first_name"
2. Last Name: "last_name"
3. Membership ID: "membership_id"
4. Identification Number: "idnumber"
The first 3 fields load fine with the original code.
Having problems with the 4th field as it is a custom field and must be pulled from other tables.
How do I combine the previous code with the new code?
When I add the code below the form does not load & page only displays the word Error.
Please Log in or Create an account to join the conversation.
- bumble
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 76
- Thank you received: 0
3 years 8 months ago - 3 years 8 months ago #137171
by bumble
Replied by bumble on topic Creating online form with fields filled up with membership details
Could not upload the code as it kept bringing this up: "SQL injection was detected and blocked."
So uploaded an image.
So uploaded an image.
Last edit: 3 years 8 months ago by bumble.
Please Log in or Create an account to join the conversation.
Support
Documentation
Information
Copyright © 2024 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.