setQuery($queryref1); $referralem..." />

Support

  1. HScherb
  2. General
  3. Thursday, November 12 2020, 08:26 AM
  4.  Subscribe via email
Dear Easy Profile
I try to access the jsn records by 2 ways and I do not succeed. I need help.

------------By Table Query
$queryref1 = $db
->getQuery(true)
->select($db->quoteName('choose_referral'))
->from($db->quoteName('#__jsn_users'))
->where($db->quoteName('id') . " = " . $userId);
$db->setQuery($queryref1);
$referralemail140 = $db->loadResult();
//I want to display the results
JFactory::getApplication()->enqueueMessage(JText::_($queryref1), 'Message');
JFactory::getApplication()->enqueueMessage(JText::_($referralemail140), 'Message');

$queryref1 is displayed
SELECT `choose_referral` FROM `#__jsn_users` WHERE `id` = 771
The second line with $referralemail140 is not displayed

I tested
->where($db->quoteName('id') . " = " . $db->quote($userId));
SELECT 'choose_referral' FROM `#__jsn_users` WHERE `id` = '771'
The second line with $referralemail140 is not displayed

-----------By JsnHelper
At the beginning of the php I declared
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
and tried
$userjsn=JsnHelper::getUser($userId);
$userjsn=JsnHelper::getUser(); echo $userjsn->getValue('choose_referral');
Nothing happens
$userjsnrefmail = $userjsn->->getValue('choose_referral');
It occurs unexpected '->' (T_OBJECT_OPERATOR)

Please, how can I get the value of the 'choose_referral' field in a variable?.
admin Accepted Answer
Admin
Hi,
which field type have you used for choose_referral field?

$userjsnrefmail = $userjsn->->getValue('choose_referral');
It occurs unexpected '->' (T_OBJECT_OPERATOR)
the error is due to double "->->" in the code
  1. 3 weeks ago
  2. General
  3. # 1
HScherb Accepted Answer
Pro
Hi
A lot of thanks for quick replay
Alias : choose_referral
Field type : select
Multiple selection: No
Table : #__users
Column for Value : email
Column for Text : username
Sql WHERE parameter (optional) : id IN (SELECT user_id FROM #__user_usergroup_map WHERE group_id = 11)
Filter : disabled

I simply want to get the value
atestbiza@aergied.com
in a variable
Attachments (2)
  1. 3 weeks ago
  2. General
  3. # 2
HScherb Accepted Answer
Pro
Sorry I forgot
Yes, with a single > no error but the variable $userjsnrefmail is not displayed
$userjsnrefmail = $userjsn->getValue('choose_referral')
JFactory::getApplication()->enqueueMessage(JText::_($userjsnrefmail), 'Message');
  1. 3 weeks ago
  2. General
  3. # 3
admin Accepted Answer
Admin
Have you tried to specify an explicit user ID?
for example:
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
$userjsn=JsnHelper::getUser(705);
$userjsnrefmail = $userjsn->getValue('choose_referral');
JFactory::getApplication()->enqueueMessage(JText::_($userjsnrefmail), 'Message');
  1. 3 weeks ago
  2. General
  3. # 4
HScherb Accepted Answer
Pro
Thank you. Super support
I made a test following your instruction and
-------If I use an explicit user id of an existing user, it is displayed
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
$userjsnexplicit=JsnHelper::getUser(773);
$userjsnrefmailexplicit = $userjsnexplicit->getValue('choose_referral');
JFactory::getApplication()->enqueueMessage(JText::_($userjsnrefmailexplicit), 'Message');
The choose_referral of 773 is displayed (angelinawright@aergied.com)
------OK But the code is at the end of the REGISTRATION PROCESS
If it is the new user, it is not displayed
$userjsn=JsnHelper::getUser($userId);
$userjsnrefmail = $userjsn->getValue('choose_referral');
JFactory::getApplication()->enqueueMessage(JText::_($userjsnrefmail), 'Message');
Nothing
----- I made a test with explicit awaited userid (774) >>> not displayed

The code is added in a
public function onUserAfterSave($user, $isNew, $result, $error)
$userId = JArrayHelper::getValue($user, 'id', 0, 'int');

Of course, I had already tested
JFactory::getApplication()->enqueueMessage(JText::_($userId), 'Message');
The new one $userId 774 is correctly displayed

But how with the jsn fields ?...
Attachments (1)
  1. 3 weeks ago
  2. General
  3. # 5
admin Accepted Answer
Admin
Hi,
in which plugin have you added your code? it is a system or user plugin?

Basically Easy Profile store data from a user plugin called "Easy Profile - User Plugin", so you code need to triggered after this Easy Profile plugin....it need to be a user plugin (not system plugin) and need to be triggered after "Easy Profile - User Plugin" plugin (you can manage order from Extension->Plugins)
  1. 3 weeks ago
  2. General
  3. # 6
HScherb Accepted Answer
Pro
HI EP
I did not know. I watched a video on a collegue's website How to reorder the plugins. And code
$queryref1 = $db
->getQuery(true)
->select($db->quoteName('choose_referral'))
->from($db->quoteName('#__jsn_users'))
->where($db->quoteName('id') . " = " . $userId);
$db->setQuery($queryref1);
$referralemail140 = $db->loadResult();
works OK My problem is solved. I can add the new customer to the partner
I really thank you a lot.

I tell you simply that
$userjsn=JsnHelper::getUser($userId);
$userjsnrefmail = $userjsn->getValue('choose_referral');
JFactory::getApplication()->enqueueMessage(JText::_($userjsnrefmail), 'Message');
Does not display the choose_referral value

If it may help....
Best regards.
  1. 3 weeks ago
  2. General
  3. # 7
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.