Skip to:
Content
Pages
Categories
Search
Top
Bottom

Working Member List?

  • @tanikaakina

    Member

    I am really interested in finding a member list plugin that works with 1.0. I tried the one made by rayd but it does not work. I get “Page not found”

    I tried the wordress and bbpress intergration so i could use the wordpress plugin but it really messed up my forums so I reverted back. Any Ideas on how I could make this work?

Viewing 17 replies - 1 through 17 (of 17 total)
  • @kevinjohngallagher

    Member

    I’m sure there were a few ones around during 0.9, and one of them may work.

    That said, I wrote my own page in PHP which just listed the members from the database. Ideal? far from it. Works though.

    @_ck_

    Participant

    It’s very easy to make a list of members and you can use some of the built in bbPress functions. I guess I’ll turn that into a lesson here in this topic.

    @_ck_

    Participant

    First we need to gather the list of users who are not inactive or blocked.

    This unfortunately requires a much more complicated query because of how wordpress/bbpress stores the user status in the meta, and in a way that cannot be quickly queried.

    ie. this simple query is not good enough:

    $query=”SELECT ID FROM $bbdb->users WHERE user_status=0 ORDER BY user_registered DESC”;

    So the following will work up to mid-sized forums, if you have over 100k users, it’s probably a bad approach because it’s non-indexed in mysql and the query will require a complete table-scan.

    global $bbdb;
    $query="SELECT ID FROM $bbdb->users as t1 LEFT JOIN $bbdb->usermeta as t2 on t1.ID=t2.user_id WHERE user_status=0 AND (meta_key='$bbdb->prefix"."capabilities' AND NOT (meta_value LIKE '%inactive%' OR meta_value LIKE '%blocked%')) ORDER BY user_registered DESC";
    $results=$bbdb->get_col($query);

    (we’re going to deal with pagination later)

    $results will now contain all the active user IDs, newest members first (or false if the query failed for some reason).

    Since bbpress.org is screwing up code now, I’m putting it also here:

    http://pastebin.com/embed_iframe.php?i=t3BX3i10

    @_ck_

    Participant

    Actually I guess I will jump ahead and show how to make this into a view because otherwise we won’t have a proper place for it and it will get awkward to test.

    This is the mashup I’ve come up with over the years as the “simplest way”. bbPress unfortunately requires a fake, wasted query for it’s views because the original designers wanted you to use their proprietary query method which only deals with topics, so we have to bypass it.

    add_action(‘bb_custom_view’,’member_list’);

    $fakequery=array(‘started’ => ‘>0′,’append_meta’=>false,’sticky’=>false,’topic_status’=>’all’,’order_by’=>1,’per_page’=>1), false);

    bb_register_view(“member-list”,”Member List”,$fakequery);

    So there we’ve registered a view called “Member List” that will use the url/tag “?view=member-list” or “view/member-list

    http://pastebin.com/embed_iframe.php?i=CbnYfKiy

    @_ck_

    Participant

    Now we need a proper function to process/display the view output.

    Because we are essentially tricking bbPress into doing this view for us, we have to make sure we do all the output ourselves, like this mini-example

    function member_list($view='') {
    if (!empty($view) && $view!='member-list') {return;}
    bb_send_headers();
    bb_get_header();
    // do view stuff here
    bb_get_footer();
    exit;
    }

    first we make sure the view is for us, if so we send any http headers, then we send any bbPress html headers like in a normal page (meta, css, etc.) then we do our view, then we send the bbPress footer and we force PHP to stop afterwards.

    @kevinjohngallagher

    Member

    _ck_ this is excellent,

    could I ask for something additional please.

    For a given cusotm view, how would one load in a template file?

    Is there a particular call, or do we just fire through a bog standard include?

    Thank you!

    @_ck_

    Participant

    Here is a working mini example of the view with the user query.

    raw: http://pastebin.com/raw.php?i=xXant1dX

    fancy: http://pastebin.com/embed_iframe.php?i=xXant1dX

    download: http://bbshowcase.org/plugins/member-list.zip

    (download mirror): http://pastebin.com/download.php?i=xXant1dX

    It’s been made (much) more complex because of the pagination.

    But please ask questions if you want to learn more.

    You can now access any of these variables in the output section near the bottom, or you can use many internal bbPress API functions.

    $user->ID

    $user->user_login

    $user->user_pass

    $user->user_nicename

    $user->user_email

    $user->user_url

    $user->user_registered

    $user->user_status

    $user->display_name

    please note the GT thingie you are seeing above is really a greater than symbol

    Dig through the bbpress file “template-functions.php” if you want to see what other internal functions are available to you.

    Look for ones that accept $user_id as the variable and you can probably use it.

    Much more advanced topics would include overriding the internal pagination per page limit and changing/repeating the navigation but I am not going to cover right now.

    @_ck_

    Participant

    Kevin, bbPress has a function to include a template.

    ie. bb_load_template( 'tags.php' );

    You can see it at the end of many of the files in the root

    But you may find the behavior unpredictable and may want to just use an include instead, in which case you’d have to calculate the current template folder yourself, which is difficult.

    @kevinjohngallagher

    Member

    [you] may want to just use an include instead, in which case you’d have to calculate the current template folder yourself, which is difficult.

    Yeah, I’ve hit road blocks with both in the past, and was cheekily hoping you’d have a magic solution up your sleve. I might just load them as plugins which can call a nicely relative file. (not ideal though)

    Thanks for your time, this thread is going to be helpful to alot of folks I think.

    @_ck_

    Participant

    I’ve now cleaned up the plugin design a little and made the view and output functions separate so it’s easier to understand the flow.

    All anyone has to do now is just change the output to their desire near the very the bottom of the code.

    @tanikaakina

    Member

    Thank you _ck_ I’m going to try this out today

    @tanikaakina

    Member

    Thank you again and for taking the time out explaining not just the how but the why and what behind it. I learned something, I wanna learn php now. Much thanks!

    @ajtruckle

    Participant

    Thanks for this plugin. Sorry if this is a dumb question – but suppose I add this as a a plugin, how do I actually use it to present data on a page? A shortcode?

    @ajtruckle

    Participant

    I tried to import and activate this plugin and i got an error on activation:

    Fatal error: Uncaught Error: Call to undefined function bb_register_view() in …/wp-content/plugins/ts-member-list-view/member-list.php:8 Stack trace: #0 …/wp-admin/includes/plugin.php(2141): include() #1 …/wp-admin/plugins.php(175): plugin_sandbox_scrape(‘ts-member-list-…’) #2 {main} thrown in …/wp-content/plugins/ts-member-list-view/member-list.php on line 8

    @ajtruckle

    Participant

    I noticed that bb_register_view is now bbp_register_view. But when I changed that the whole website threw a wobbly!

    @robin-w

    Moderator

    this is code from bbpress version 1 – 9 years ago, unlikely to work

    @robin-w

    Moderator

    bbpress version 2 just uses WordPress users, so look at WordPress list members plugins

    for instance

    Members List Plugin

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