Plugin Directory

Changeset 1947153


Ignore:
Timestamp:
09/26/2018 04:25:37 AM (8 years ago)
Author:
cometchat
Message:

get buddypress friends using on fly method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cometchat/trunk/includes/cometchat_cloud.php

    r1936608 r1947153  
    115115        }
    116116
     117        if(function_exists('bp_get_friend_ids')) {
     118            $friends = bp_get_friend_ids($user_id);
     119            if(empty($friends)){
     120                $friends = "";
     121            }
     122        }
    117123        $user_info = array(
    118             "id"    => $user_id,
    119             "n"     => $user_name,
    120             "dn"    => $display_name,
    121             "a"     => $avatar,
    122             "l"     => $link,
    123             'role'  => $role
     124            "id"        => $user_id,
     125            "n"         => $user_name,
     126            "dn"        => $display_name,
     127            "a"         => $avatar,
     128            "l"         => $link,
     129            "role"      => $role,
     130            "friends"   => $friends
    124131        );
    125132        $cc_base = json_encode($user_info);
    126     }
    127 }
    128 
    129 /**
    130  * addCometChatFriends
    131  * Return add friends to cometchat table
    132  * @param (type) no param
    133 */
    134 function addCometChatFriends() {
    135     global $cc_clientid;
    136     global $current_user;
    137     $user_id = $current_user->ID;
    138 
    139     if(function_exists('bp_get_friend_ids')) {
    140 
    141         $friends = bp_get_friend_ids($user_id);
    142         $friends_data = array("id"=>$user_id,"f"=>$friends);
    143         $friends_ids = json_encode($friends_data);
    144         $site_url = get_site_url();
    145         $protocol = parse_url($site_url);
    146         $request_url  = $protocol['scheme'].'://'.$cc_clientid.'.cometondemand.net/cometchat_update.php';
    147 
    148         if(function_exists('curl_init')){
    149             $result = wp_remote_post($request_url, array(
    150                     'method' => 'POST',
    151                     'body' => 'userinfo='.$friends_ids
    152                 )
    153             );
    154         }
    155133    }
    156134}
     
    240218
    241219if(function_exists('bp_is_active')) {
    242     add_action('init','addCometChatFriends');
    243220    add_action( 'groups_group_create_complete',  'createGroupInCometChat' );
    244221    add_action( 'groups_delete_group',  'deleteGroupFromCometChat' );
Note: See TracChangeset for help on using the changeset viewer.