json api and buddypress xprofile fields
-
Ok, i need somebody who knows php well, to get this done.please…
ive narrowed it down to this :
the JSON API get author info:
function JSON_API_Author($id = null) {
if ($id) {
$this->id = (int) $id;
} else {
$this->id = (int) get_the_author_meta(‘ID’);
}
$this->set_value(‘slug’, ‘user_nicename’);
$this->set_value(‘name’, ‘display_name’);
$this->set_value(‘first_name’, ‘first_name’);
$this->set_value(‘last_name’, ‘last_name’);
$this->set_value(‘nickname’, ‘nickname’);
$this->set_value(‘url’, ‘user_url’);
$this->set_value(‘description’, ‘description’);
$this->set_author_meta();
//$this->raw = get_userdata($this->id);
}function set_value($key, $wp_key = false) {
if (!$wp_key) {
$wp_key = $key;
}
$this->$key = get_the_author_meta($wp_key, $this->id);
}and the buddy press get xprofile value:
*/
public function profile_get_profile() {
$this->init(‘xprofile’);
$oReturn = new stdClass();if ($this->username === false || !username_exists($this->username)) {
return $this->error(‘xprofile’, 1);
}$oUser = get_user_by(‘login’, $this->username);
if (!bp_has_profile(array(‘user_id’ => $oUser->data->ID))) {
return $this->error(‘xprofile’, 0);
}while (bp_profile_groups(array(‘user_id’ => $oUser->data->ID))) {
bp_the_profile_group();
if (bp_profile_group_has_fields()) {
$sGroupName = bp_get_the_profile_group_name();
while (bp_profile_fields()) {
bp_the_profile_field();
$sFieldName = bp_get_the_profile_field_name();
if (bp_field_has_data()) {
$sFieldValue = bp_get_the_profile_field_value();
}
$oReturn->profilefields->$sGroupName->$sFieldName = $sFieldValue;
}
}
}
return $oReturn;
}now i need to combine both results and merge them to the JSON_API_Author function ..
please ,anyone , im completely lost here…
any help?
- The topic ‘json api and buddypress xprofile fields’ is closed to new replies.