0

How can I programatically change the ufid and contact id of CIVICRM?

I know the table civicrm_uf_match holds the matching ids but even if I change that it doesn't matter. It seems like the ids are put into session but even if I try to change the session variables via:

$session =& CRM_Core_Session::singleton( );
$session->set( 'userID' , $myjoomauserid); 
$session->set( 'ufID' $mycivicid); 

everytime I click renew member its the same member. I need to be able to change it all on the fly for my custom user interface. It allows a user to view all civicrm contacts and memberships associated with one email address. Then the user can edit renew whichever ones they want -- I created this to allow families to be able to edit there kids and for clubs to edit their members. Any help with how this works would be geatly appretiated. I used to set the ids in the civicrm_uf_match programatically then log the user out of joomla and log them back in but that doesnt seem to work anymore since the civicrm uprade to 4.6

I am not sure if synchronizeUFMatch as seen in some of the ecode is the route i neeed to look into such as

$ufmatch = self::synchronizeUFMatch($user, $userSystemID, $uniqId, $uf, NULL, $ctype, $isLogin);

0

Does Joomla have an equivalent of Masquerade, where you can temporarily become another user? This can also (once per request) be done programmatically with the masquerade_switch_user and masquerade_switch_back functions.

1
  • Yes and this was eventually how I solved the problem. – David Richmond Aug 17 '16 at 14:58
1

Well as usual it turns out to be simple. I just need to manually make the link in civicrm_uf_match via my program then simply change the session variables via:

require_once 'administrator/components/com_civicrm/civicrm.settings.php'; require_once 'administrator/components/com_civicrm/civicrm/CRM/Core/Config.php'; require_once 'administrator/components/com_civicrm/civicrm/api/v3/UFMatch.php'; require_once 'administrator/components/com_civicrm/civicrm.settings.php'; require_once('CRM/Core/DAO.php');

$session = CRM_Core_Session::singleton();

$session->set('ufID' , $ufid);     //joomla ID
$session->set('userID' , $userid); //civi contact id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.