Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Seems great 🙂
    But I’m really confused how it’s working..
    I don’t understand all that myrole, yourrole and _member_role.

    The script are supposed to go to bp_custom.php, right?

    Thanks for your reply!
    Yes, I have seen that.. But I can’t get it to work.
    I’m supposed to correct the function ($field_name and $field_value) right?

    So:

    function my_custom_ids( $genre, $field_value = 'Rock' ) {
      
      if ( empty( $genre ) )
        return '';
      
      global $wpdb;
      
      $field_id = xprofile_get_field_id_from_name( $genre ); 
     
      if ( !empty( $field_id ) ) 
        $query = "SELECT user_id FROM " . $wpdb->prefix . "bp_xprofile_data WHERE field_id = " . $field_id;
      else
       return '';
      
      if ( $field_value != '' ) 
        $query .= " AND value LIKE '%" . $field_value . "%'";
          /* 
          LIKE is slow. If you're sure the value has not been serialized, you can do this:
          $query .= " AND value = '" . $field_value . "'";
          */
      
      $custom_ids = $wpdb->get_col( $query );
      
      if ( !empty( $custom_ids ) ) {
        // convert the array to a csv string
        $custom_ids_str = 'include=' . implode(",", $custom_ids);
        return $custom_ids_str;
      }
      else
       return '';
       
    }

    ^
    That script is in my function.php
    I have also tried not to change $field_name and tried all case senstive options (I think).

    In members directory I have included this:
    <a href="<?php if ( bp_has_members( my_custom_ids( 'Genre', 'Rock' ) ) ) ; ?>">Rock</a>

    So that should look for what is in ‘Genre’ called ‘Rock’, and give you those when you click on the link.. What have I misunderstood?

Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar