Forum: Feature Requests

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support related to the Feature Requests premium extension please open a new premium support ticket.

Search only members with certain role?

Forums Feature Requests Search only members with certain role?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #30331

    Hello Eyal,
    first of all thanks for this amazing plugins, works like a charm.
    What we actually try to do is to extend the search function wppl_bp_query_results() in functions.php in order to find “near members” only with a certain user role (we use s2members) and would like e.g. to find only other members around me with privilege above 1 for example, which is nothing else than a specific WP role.

    After line 378 in the functions.php file I think I can add a filter over the results array which outputs only certain user levels. Anyway is there any way to do this without modifying the plugin, maybe through overwrite or else? Or maybe give parameters to the search function in order to search only inside a given range of roles?

    Thanks in advance for feedback;)


    Ivo Marino, B.Sc. IT
    ivo.marino@tiger-team.it
    Tiger Team Software Solutions

    #30340

    Hi Ivo,
    just to let you know before you Make any modifications that I am about to release a beta version for new 2.0 update. Hopefully today or tomorrow.
    This is a major update where most of the code and functions have been modified. This mean much better and cleaner code than what is was before.
    The new update also works directly with the new BP_query_user that was introduced in buddypress 1.7.

    As for your question, right now I cannot see a “clean” way to do what you want but adding an “if” statement which will check for the user role into the members loop.

    However, I can take a look later and see if there is a way todo it using the bp_user_query (maybe a parameter) or if it will be easier to inject a direct SQL statement into the query.

    I will let you know later and please let me know if you’d like to test the beta when it is ready.

    Thank you
    Eyal

    #30339

    OK, thanks Eyal! What I’ve done actually for now is adding:


    for ($i = 0; $i < count($total_ids); $i++) {
    $my_id = $total_ids[$i]->member_id;
    if(user_can($my_id, "access_s2member_level0"))
    echo 'User ID# 123 CAN access content protected at Level #0.';
    else if(user_cannot($my_id, "access_s2member_level0"))
    echo 'User ID# 123 CANNOT access content at Level #0.';

    }

    which seems to work, filters IDs out from results and checks it’s s2members capability, seems OK for now;) I’ll sty tuned!

    #30338

    Awesome!
    Also result by user role is a good idea for a simple add-on 🙂

    Still, let me know about the beta testing
    Thank you

    #30337

    I’m here for beta testing, just drop me a line where to get latest code. I’ll show you later what we’re doing with your plugin, it’s exactly what we were looking for our customer!

    #30336

    so actually this is what I’ve added after line 378 in functions.php:


    for ($i = 0; $i < count($total_ids); $i++) {

    $my_id = $total_ids[$i]->member_id;

    if(user_cannot($my_id, "access_s2member_level1")) {
    unset($total_ids[$i]);
    }
    }

    it filters out members which have not at least membership level 1 (which we call Premium in our network). Maybe you can add and parametrize this option in the upcoming beta in some way, can be useful to many I think, thanks in advance Eyal,

    I.

    #30335

    I will try to add the option but not sure i will be able too.This update had been taking forever because i kept adding more and more features that i had on the todo list ( When usually i add few for each update). I also change the entire code, the payment system and i am working on the new site of Support. so There is a lot going on.

    I will try to see if there is a “better” solution for what you are looking for. However, the code you have above is pretty simple and clean.

    #30334
    jesse1341
    Member

    Hello I am also interested in doing this, please keep me updated as I want to by plugin if this is possible. Can anyone else do this?

    #30333

    Hi jesse,
    what exactly are you trying to do? Filter results by user role?

    #30332
    jesse1341
    Member

    Let me pm you info

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.