setQuery($queryref1); $referralem..." />
  1. HScherb
  2. General
  3. Thursday, November 12 2020, 08:26 AM
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. more than a month 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
[email protected]
in a variable
  1. more than a month 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. more than a month 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. more than a month 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 ([email protected])
------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 ?...
  1. more than a month 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. more than a month 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. more than a month 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.