Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can someone point me at a basic starter for programming using Buddypress?


  • Norman Cates
    Participant

    @normancates

    I’ve been wandering around in BuddyPress and WordPress.

    I’ve been slowly working out how to get data out of WordPress.

    But I CANNOT figure out how to get data out of Buddypress.

    In this page:

    bp_profile_field_data()

    There is some code that indicates how to get data back.

    But no matter how I do it, I can’t get it to return any data.

    I’m running the code in the middle of a WordPress page using a PHP plugin, rather than trying to create a page from scratch.

    I’ve got it returning WordPress user data fine.

    But getting any actual xProfile field data out is proving…. impossible.

    I’m sure I’m ignorant of something really basic about how it all works…

    Thanks for any help and pointing at relevant webpages.

Viewing 7 replies - 1 through 7 (of 7 total)

  • Norman Cates
    Participant

    @normancates

    So I realised looking at this page:

    Profile Fields Loop

    That I have no idea how it’s getting its data.

    There’s no arrays or variables being set. There’s these functions:

    bp_has_profile()
    bp_profile_groups()

    and so on.

    But none of these do any assignments of variables or results.

    I suspect my PHP/programming knowledge is way out of date. Because there’s something sophisticated or hidden going on here with those functions that I just don’t understand.

    As usual glad to be pointed at background reading…


    Venutius
    Moderator

    @venutius

    That’s because these are loop functions, designed to provide data from the current profile in the loop.

    Which profile group are you looking to get the data for, and which field?


    Norman Cates
    Participant

    @normancates

    I’m lookig to get the xprofile data out. And also poke it in.

    I’m afraid that you might have to get more basic than what you’ve said.

    What’s a loop function and how does it pass data from one function to another. I interpret a loop as a “for each” or a “while” or similar that loops through an array or whatever.

    Are these objects or classes that are doing something I don’t understand?

    Glad to be told that I need to read up on xxxx or yyyy.

    At the moment it just looks like black magic.


    shanebp
    Moderator

    @shanebp

    When not using a BP profile loop, try using xprofile_get_field_data.


    Venutius
    Moderator

    @venutius

    Loop functions are a pretty basic feature of WordPress, in WP 101 terms it’s basically lesson 2 – how the posts page displays a list of all posts. It does this by having a loop – using a function to pull in all posts (or in bp members or groups) then using a while loop to iterate through all those posts, members groups etc, depending on the context.

    So a bp Loop looks something like this:

    If has_members:
    While has_members:
    print out the info you want
    End while
    Else
    // there were no members

    Norman Cates
    Participant

    @normancates

    Sweet.

    The problem I have is that I’m used to using variables in loops. $variable etc.

    But the loop page is only using functions (AFAIK).

    I assume that’s a standard PHP capability, but I don’t know how to search for what that’s called to read up on it…

    I also was ignorant of the alternative syntax for control structures. I’ve read up on it and wanted to check that:

    while ( bp_profile_groups() ) : bp_the_profile_group();
    
    endwhile;

    was 100% equivalent to:

    while ( bp_profile_groups() ){
          bp_the_profile_group();
    
    }

    I’ve actually tried putting that exact code, in both syntaxes, into my test page.

    And it kind of silently fails. It brings up bits of the page, but then stops. And I can’t even pull up the source or the Chrome Developer window.

    How do the functions in the loop get their parameters to return values?

    Is everything being set globally? If so, then how do we know which functions have to be caleld first to set up the variables?

    Thanks for all your help. 🙂


    Norman Cates
    Participant

    @normancates

    I’ve tried xprofile_get_field_data using this code:

    $args = array(
        'field'     => 'Nickname'
    );
    
    $result = xprofile_get_field_data($args); 
    print ("<br><br>");
    print ("XProfileData");
    print ("<br>");
    var_dump($result);

    But all it does is return “FALSE”

    That xprofile field definately exists

    Thanks to someone on WPMU dev, I tried this:

    $profile_data = BP_XProfile_ProfileData::get_all_for_user( 1 );
    echo '<pre>';
    print_r($profile_data);
    echo '</pre>';

    This returns the Profile fields…

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar