web
·
Added a discussion

I try to get this infos (gender,birthday,location ) , but without success

    $oProfile = BxDolProfile::getInstance($iProfileId);
    $aProfileInfo = $oProfile->getInfo();
    $aProfileGender = $aProfileInfo['gender'];

How can i do?

  • 1990
Comments
    • Hello!

      First of all, you need to check the fields in the return result like this way:

      echoDbg($aProfileInfo);
      
      • Hello,

        This result

        Array
        (
            [id] => 14988
            [account_id] => 1
            [type] => bx_persons
            [content_id] => 7484
            [cfw_value] => 2147483647
            [cfw_items] => 31
            [cfu_items] => 31
            [cfu_locked] => 0
            [status] => active
        )
        

        So how can i get gender,birthday and location please ?

        • ok, i finally did it!

              $oProfile = BxDolProfile::getInstance($iProfileId);
              $aProfileInfo = $oProfile->getInfo();
              $sViewerModule = $oProfile->getModule();
              
              
              $aSegViewer = [];
          
                      $aViewerInfo = bx_srv($sViewerModule, 'get_info', [$oProfile->getContentId(), false]);
                      
                      if(!empty($aViewerInfo) && is_array($aViewerInfo)) {
                          if(!empty($aViewerInfo['gender']))
                              $aSegViewer['gender'] = $aViewerInfo['gender'];
          
                          if(!empty($aViewerInfo['birthday']))
                              $aSegViewer['age'] = bx_birthday2age($aViewerInfo['birthday']);
          
                          if(!empty($aViewerInfo['location'])) {
                              $aLocation = unserialize($aViewerInfo['location']);
                              if(!empty($aLocation['country']))
                                  $aSegViewer['country'] = $aLocation['country'];
                          }
          
                          if(!empty($aViewerInfo['tags']))
                              $aSegViewer['tags'] = explode(',', $aViewerInfo['tags']);
                      }
                 
              echo $aSegViewer['gender'];echo $aSegViewer['age'];echo $aSegViewer['country'];
          
          Login or Join to comment.