Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter rufrage

    (@rufrage)

    Sure, I sent you an email!

    Thread Starter rufrage

    (@rufrage)

    Unfortunately, now the search doesn’t output any members anymore. Instead, it says “No users found” (something like this, I have it with another language). Also, when I access the directory without any search queries, but via permalink, I can’t see any members..

    Thanks for you suggestion anyways – can you maybe think of another solution?
    Greetings,
    Rufrage

    Thread Starter rufrage

    (@rufrage)

    Edit: The regular BuddyPress search works fine and shows only the correct members (once I put in more that 3 characters – else it shows everybody?). This must be an issue conflicting the custom code and the plugin..

    Thread Starter rufrage

    (@rufrage)

    Hey!

    I found code, where I put the following into functions.php

    function xfield_member_filter( $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, value FROM " . $wpdb->prefix . "bp_xprofile_data WHERE field_id = " . $field_id . " ORDER BY value" ;
      else
       return '';
      // var_dump($query); die;
      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 '';
       
    }
    
    function alphabetize_by_custom_field( $bp_user_query ) {
      ;
      if ( 'alphabetical' == $bp_user_query->query_vars['type'] ) {
        $bp_user_query->uid_clauses['orderby'] = "ORDER BY FIELD(u.ID," . $bp_user_query->query_vars['include'] . ")";  
        $bp_user_query->uid_clauses['order'] = "";  
      }
    }
    add_action ( 'bp_pre_user_query', 'alphabetize_by_custom_field' );

    and this in the members-loop.php, where the usual request would stand:
    <?php if ( bp_has_members( xfield_member_filter( 'yourcustomfield ' ).'&type=alphabetical' ) ) : ?>

    It works, the fields are now gettings sorted by the custom field (which must be set instead of yourcustomfield in the last code-line).
    Unfortunately, it does no longer consider the search key terms for the query anylonger, thus showing the entire members dictionary.
    Do you have any clue on how to put your plugins’ search filter after this custom filter?

    Best regards,
    Rufrage

    • This reply was modified 8 years, 1 month ago by rufrage.
    Thread Starter rufrage

    (@rufrage)

    Edit: The plugin author did not only create an excellent plugin, he also created additional hooks for my feature request and helped me with the implementation of such – even though this feature request was interesting for only a rather small group of people. Recommend 6/5 stars!

    Thread Starter rufrage

    (@rufrage)

    Did you get any chance to have a thought on it yet?
    I’ve been reading a little bit into the topic lately and I assume I could add a field to users that I, as an admin can fill with IDs (this makes an array of IDs) of accounts, that the user is able to rate. When accessing the profile of another user, a filter is put upon the “Rate-Button”, so I can only use/see it, if the profile id i’m just visiting is in the “allowed-array” of the current user. Else, it will just not allow a rating, but display the current rating either way. Would you, as the plugin developer, think, that this would make sense, or are there issues I will face but can not yet detect in plain theory? Or do you even thought of a better approach yet?

    Thanks in advance for your reply.
    Have a nice weekend!

    Thread Starter rufrage

    (@rufrage)

    Hello,

    thanks for your reply and your effort in finding a solution.
    I will look for a solution myself and post it in here, once I find one.

    Greetings!

    Thread Starter rufrage

    (@rufrage)

    I made some progress already – using

    <?php static $currentjob = "";
    		$memberjob = bp_get_member_profile_data( 'field=T?tigkeit' );
    		if(strcmp($currentjob, $memberjob) !== 0){
    			$currentjob = $memberjob;
    			echo "<div class=\"membersjob\">$currentjob</div>";
    		}
    		?>

    right below the
    <?php while ( bp_members() ) : bp_the_member(); ?> line, I can check if the member has the same job as his predecessor and only show the headline, if this is not the case.
    However, the users are not yet sorted by the value in their job field (“T?tigkeit” in my language), so it occurs to happen, that a certain headline appears more than once, simply because the predecessor had another job.

    How can I have the list sorted by the members’ jobs, so that everythings works out?
    Thanks in advance!

    Thread Starter rufrage

    (@rufrage)

    Thanks for the quick reply!
    I am quite new to actions and filters, but willing to do this! Maybe you can provide a starting point and/or 1-2 sentences on how you think this could be done, nothing too specific to save your time.

    Thanks again ??

    Thread Starter rufrage

    (@rufrage)

    This should be in support forums, but the plugin is 5 stars already anyways.
    Copying this to support forums for a better overview ??

    I assume you use the text-field to enter your shortcode? When in edt mode, you can switch between visual and text. Check the “text” field for added code and remove it, so that it contains the same information as the “visual” field. This solved it for my woocommerce problem at least.. Good luck!

    Thread Starter rufrage

    (@rufrage)

    So while I am waiting for your answer, I was doing some research and found out, that I probably need to create an own plugin that creates “requirement-metaboxes” for your post-type and uses your action hook when displaying a poll to check, if the metaboxes match the profile info of the logged-in Buddypress User. I’ll try to figure this out and might have success with all the tutorials out there. What I would appreciate, is if you could name the filter you built in to display the polls ?? Thanks a lot and have a great Sunday.

Viewing 12 replies - 1 through 12 (of 12 total)