BuddyBoss Home – Web Support Forums Themes BuddyBoss theme tip: showing all member websites on a single page

  • This topic has 1 reply, 2 contibutors, and was last updated 9 years ago by Anonymous.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Question

    #50790
    @mth75

    Tip: when you use a custom xprofile field: “Website” you can create a single page i.e. Links with the attached file as template (copy it to your child theme). The code outputs: avatar – member name – website.

    Add the following to your function.php:

    // xprofile search function
    function my_custom_ids( $field_name, $field_value = '' ) {
      
      if ( empty( $field_name ) )
        return '';
      
      global $wpdb;
      
      $field_id = xprofile_get_field_id_from_name( $field_name ); 
     
      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 '';
       
    }

    Maybe this comes in handy for some of you!

    You can see the action on http://www.starry-night.nl/links/

    Answers

    #51006

    Anonymous
    @

    Hi @mth75, Thanks for the suggestion we will check it 🙂

    Regards

Viewing 2 posts - 1 through 2 (of 2 total)
  • The question ‘tip: showing all member websites on a single page’ is closed to new replies.