WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. brillfx
    Member
    Posted 11 months 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:

    "get_recent_posts&custom_fields=....."

    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.

    thanks

    http://wordpress.org/extend/plugins/json-api/

  2. dphiffer
    Member
    Plugin Author

    Posted 9 months 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
    Member
    Plugin Author

    Posted 9 months 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 = ...;
    }

Reply

You must log in to post.

About this Plugin

About this Topic