Store connection user_ids Auto Action

6 months 2 weeks ago #335390 by PaceOnline
Store connection user_ids Auto Action was created by PaceOnline
We are using a field called myconnections to store the user_ids of a users connections so that we can we can pass the array via REST. We update it with a code action but it doesn't seem to be working and I can't see why. The result of the following code is that nothing is ever stored in the field;

$user_id = $user->id;
if($user_id){
   $db   = JFactory::getDBO();
   $query = "SELECT id FROM #__comprofiler WHERE user_id = ".$user_id;
   $db->setQuery($query);
   $check_id = $db->loadResult();

   if($check_id){
        $query = "SELECT (REPLACE(REPLACE(asset,'.connection',''),'profile.','')) AS asset_user_id FROM #__comprofiler_plugin_activity WHERE user_id = ".$user_id;
        $db->setQuery($query);
        $cb_myconnections = $db->loadColumn();

        if($cb_myconnections){ $cb_myconnections = implode('|*|',$cb_myconnections); }

       $profile = new stdClass();
       $profile->id = $check_id;
       $profile->cb_myconnections = $cb_myconnections;
       $db->updateObject('#__comprofiler', $profile,'id');
   }
}

Please Log in to join the conversation.

6 months 2 weeks ago #335394 by krileon
Replied by krileon on topic Store connection user_ids Auto Action
You shouldn't need to store them at all. Use a CB Query Field and query for that information then substitute your query field into your outbound REST usage (I assume you're using a Request action here?). The below for example will give you a comma separated list of user ids.

Query:
SELECT `memberid` FROM `#__comprofiler_members` WHERE `referenceid` = '[user_id]'
Output: Multiple Rows
Columns: Single Column
Delimiter: Comma

Now you don't need to deal with duplicate data issues or synchronization issues.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: PaceOnline

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.136 seconds

Facebook Twitter LinkedIn