Help in adding xprofile values from buddypress to JSON API (3 posts)

  1. brillfx
    Posted 3 years ago #

    Hi , first JSON API is awesome!
    its a huge help , so thanks for that!

    ok , im trying to add my xprofile fields to json api's output.
    basically people register through buddypress and add xprofile fields, however im reading the autors info into my application from:


    i was wondering if anyone knows how to add the xprofile fields to the author's info and if its possible.
    i know there is a json api for bbpress but that will just increase my query time so that's why i want it with the posts im getting .

    im not so great with php and still learing how this works
    any help would be highly appreciated.



  2. dphiffer
    Plugin Author

    Posted 2 years ago #

    Hi brillfx, I'm replying to this a bit late, but you should be able to do this using an action hook or a filter. These aren't very well documented as of yet, but the two you might try hooking into are 'json_api_encode' or 'json_api_[post type]_constructor'.

  3. dphiffer
    Plugin Author

    Posted 2 years ago #

    Something like this:

    add_action('json_api_post_constructor', 'add_xprofile_fields');

    function add_xprofile_fields($post) {
      $author_id = $post->author->id;
      $post->author->xprofile = ...;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic