Answers.Body: <p>Does Joomla have an equivalent of <a href="https://www.drupal.org/project/masquerade" rel="nofollow">Masquerade</a>, where you can temporarily become another user? This can also (<a href="https://www.drupal.org/node/2514548" rel="nofollow">once per request</a>) be done programmatically with the masquerade_switch_user and masquerade_switch_back functions.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-17T14:58:03.367Z
Answers.Text: Yes and this was eventually how I solved the problem.
Answers.UserDisplayName: David Richmond
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-21T14:46:43.953Z
Answers.LastActivityDate: 2016-03-21T14:46:43.953Z
Answers.UserDisplayName: DaveFF
Answers.Body: <p>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:</p>
  
  <p>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');</p>
  
  <pre><code>$session = CRM_Core_Session::singleton();
  
  $session-&gt;set('ufID' , $ufid);     //joomla ID
  $session-&gt;set('userID' , $userid); //civi contact id
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-18T06:39:41.910Z
Answers.LastActivityDate: 2016-02-18T06:39:41.910Z
Answers.UserDisplayName: David Richmond
Body: <p>How can I programatically change the ufid and contact id of CIVICRM?</p>
  
  <p>I know the table <code>civicrm_uf_match</code>  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:</p>
  
  <pre><code>$session =&amp; CRM_Core_Session::singleton( );
  $session-&gt;set( 'userID' , $myjoomauserid); 
  $session-&gt;set( 'ufID' $mycivicid); 
  </code></pre>
  
  <p>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</p>
  
  <p>I am not sure if synchronizeUFMatch as seen in some of the ecode is the route i neeed to look into such as</p>
  
  <p>$ufmatch = self::synchronizeUFMatch($user, $userSystemID, $uniqId, $uf, NULL, $ctype, $isLogin);</p>
  
Tags: <civimember>
Title: Civicm change UFID to ContactID relationship programatically
ThreadText: # Civicm change UFID to ContactID relationship programatically
  
  (Asked by: username_0 on 2016-02-18)
  
  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);
  
  **Tags:** civimember
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-03-21. Score: 0 | Accepted answer
  
  Does Joomla have an equivalent of [Masquerade](https://www.drupal.org/project/masquerade), where you can temporarily become another user? This can also ([once per request](https://www.drupal.org/node/2514548)) be done programmatically with the masquerade\_switch\_user and masquerade\_switch\_back functions.
  
  > **Comments:**
  > **username_0**: Yes and this was eventually how I solved the problem.  
  
  ---
  
  ### Answer by username_0 on 2016-02-18. Score: 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
  
  ```
  
  
  ---
  
  