예제 #1
0
/**
 * @param $account
 * @param $mapping_context
 * @return WP_User
 */
function memberful_wp_sync_member_account($account, $mapping_context)
{
    $mapper = new Memberful_User_Map();
    $user = $mapper->map($account->member, $mapping_context);
    if (!is_wp_error($user)) {
        Memberful_Wp_User_Downloads::sync($user->ID, $account->products);
        Memberful_Wp_User_Subscriptions::sync($user->ID, $account->subscriptions);
        Memberful_Wp_User_Role_Decision::ensure_user_role_is_correct($user);
    } else {
        memberful_wp_record_error(array('error' => $user->get_error_messages(), 'code' => $user->get_error_code(), 'data' => $user->get_error_data()));
    }
    return $user;
}
예제 #2
0
 public static function sync($user_id, $entities)
 {
     $syncer = new Memberful_Wp_User_Downloads($user_id);
     return $syncer->set($entities);
 }