Dynamic BPS Directory from PHP

BP Profile Search Dynamic BPS Directory from PHP

  • Author
    Post
  • #12510 Reply
    Bastian
    Guest

    Hey Andrea,

    I have a question since I want to create a user specific member directory via hidden filters but I cannot hardcode them into a shortcode-widget, instead it is dependent on a user profile field.

    But already starting easy with the simple following code is giving me no output:

    function directory_test(){
    return do_shortcode(‘[bps_directory]’);
    }
    add_shortcode(‘directory_test’, ‘directory_test’);

    Is there anything wrong with this simple approach already?

    Thanks a lot for the support !

    #12511 Reply
    Bastian
    Guest

    Additionally:

    Is the logic from the following page still working? It is not excluding the logged in user for me when pasting it into bp-customs.php…

    https://dontdream.it/exclude-users-from-search-results/

    #12512 Reply
    andrea
    Plugin Author

    Hi Bastian,

    Check out this topic:

    https://dontdream.it/support/topic/dynamic-hidden-filter-setting/

    Is this helpful? I can provide more information if you need it.

    As for your second question, that code removes the current user from the search results, not from the directory. Is that what you need?

    #12514 Reply
    Bastian
    Guest

    Hey Andrea,

    thanks a lot for the quick answer.
    This works perfectly for me.

    Could you additionally tell me how I can apply “range” for numbers though? Unfortunately the below snippet does not work…

    add_filter ('bps_hidden_filters', 'dynamic_filters');
    function dynamic_filters ($filters)
    {
    	$user_id = bp_loggedin_user_id ();
        $rooms = xprofile_get_field_data (463, $user_id);
        $filters['field_858_range'] = '1,' . $rooms;
    	
      return $filters;
    }

    Also for testing, entering a simple ‘1,3’ does not work…

    Thanks so much !

    #12517 Reply
    andrea
    Plugin Author

    Hi Bastian,

    You can try:

        $filters['field_858_range']['min'] = 1;
        $filters['field_858_range']['max'] = $rooms;
Reply to: Dynamic BPS Directory from PHP
My Information