Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to print all user profiles

  • I want to display a list of all the users on my blog (wbs80.com) and their profile information.

    I have been looking at the bbpress code and trying several tests…but unfortunately without success.

    My approach is to get the list of profile keys, get the list of users and for each user display the username and profile information. The code segment that I have is:

    <?php

    require_once (‘../../bb-load.php’);

    global $bddb;

    $profile_keys = get_profile_info_keys();

    //print_r($profile_keys);

    $userinfo = $bbdb->get_results(“SELECT * FROM $bbdb->users WHERE user_status = 0 ORDER BY ‘ID'”);

    //print_r($userinfo);

    foreach ($userinfo as $key) {

    $metainfo = $bbdb->get_results(“SELECT * FROM $bbdb->usermeta WHERE user_id = $key->ID”);

    // ???

    }

    ?>

    I don’t know how to use the “profile_keys” value(s) to access the “metainfo” data structure and extract the data.

    Any help would be greatly appreciated!

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

  • chrishajer
    Participant

    @chrishajer

    Hopefully this is only a typo here, not in your actual code:

    global $bddb;

    Should be $bbdb.


    Sam Bauers
    Participant

    @sambauers

    You aren’t inside a function so there’s no need to globalise $bbdb.

    This will get you every user (including all meta) into the array $users:

    $user_ids = $bbdb->get_col( "SELECT ID FROM $bbdb->users WHERE user_status = 0 ORDER BY id;", 0 );
    $users = bb_get_user( $user_ids );
    print_r( $users );


    chrishajer
    Participant

    @chrishajer

    Thanks Sam. I didn’t know what was wrong, but I did see the typo.

    Thanks Sam…this is exactly what I needed to get me going after being stuck for days :-)

    For completeness, here is the first working version of my code:

    <?php

    require_once(‘../bb-load.php’);

    bb_get_header();

    ?>

    <script src=”../my-js/sorttable.js”></script>

    <?php

    $tbl_header=<<<EOD

    </br>

    <h3><center><font color=”#880000″>WBS80 Registered Users</font></center></h3>

    <center><i><font size=”2″>(click on table header to sort</font>)</i></center>

    </br>

    <table class=”sortable” width=’100%’ border=’1′ cellpadding=’4′ cellspacing=’0′ align=’center’>

    <tr>

    <th>lname</th>

    <th>fname</th>

    <th>email</th>

    <th>city</th>

    <th>state/province</th>

    <th>country</th>

    </tr>

    EOD;

    $user_ids = $bbdb->get_col( “SELECT ID FROM $bbdb->users WHERE user_status = 0 ORDER BY id;”, 0 );

    foreach ($user_ids as $key => $value) {

    if ($value == 1) {

    continue;

    }

    $users = bb_get_user( $value );

    $lname = strtolower($users->last_name);

    $fname = strtolower($users->first_name);

    $email = strtolower($users->user_email);

    $city = strtolower($users->city);

    $state = strtolower($users->state);

    $country = strtolower($users->country);

    $tbl_info .=<<<EOD

    <tr>

    <td>$lname</td>

    <td>$fname</td>

    <td>$email</td>

    <td>$city</td>

    <td>$state</td>

    <td>$country</td>

    </tr>

    EOD;

    }

    $tbl_footer = “</table>”;

    $tbl =<<<TBL

    $tbl_header

    $tbl_info

    $tbl_footer

    TBL;

    print $tbl;

    ?>

    <p><h3 id=”tag”>AGE QUOD AGIS</h3></p>

    <?php bb_get_footer(); ?>

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

You must be logged in to reply to this topic.