Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • @mdrabble

    Participant

    Anyone able to offer any suggestions?

    Thanks in advance

    @mdrabble

    Participant

    I’m happy to PM a test account (non-admin) to see what is happening if that helps.

    @mdrabble

    Participant

    I dropped the above function and opted to use the following code in my bp-custom.php

    <?php
    function select_years( $retval ) {
    	global $wpdb;
    
    	$field_id = 6;
    	$value = $_GET['alumniyear']; 
    	
    	$query = "SELECT user_id FROM " . $wpdb->prefix . "bp_xprofile_data WHERE field_id = " . $field_id . " AND value = '" . $value . "'";
    
    	$year_ids = $wpdb->get_col( $query );
      
    	if ( !empty( $year_ids ) ) 
    		$retval['include'] = $year_ids;
    
    	return $retval;
    }
    ?>

    and on my members loop I have used the following.

    <?php
    if ( bp_ajax_querystring( 'members' ) =="") {
    	$queryString = "type=alphabetical&action=alphabetical&page=1";
    } else {
    	$queryString = bp_ajax_querystring( 'members' );
    }
    ?>
    
    <?php if ( bp_get_current_member_type() ) : ?>
    	<p class="current-member-type"><?php bp_current_member_type_message() ?></p>
    <?php endif; ?>
    
    <!-- Custom Code to show selected users -->
    
    <?php $year=$_GET['alumniyear'];?>
    <?php
    if ($year === NULL) {
        echo "<H3>All Alumni years</h3>";
    	 
    } else {
    	echo '<h3>Alumni Year: ' . $year .'</h3>';
    	add_filter( 'bp_after_has_members_parse_args', 'select_years' );
    }
    ?>

    It works better than the previous as I can now move between pages on all members….BUT…..

    when I am filtering the page, the page links move between pages but the filter is removed and the next page displays all members on next page.

    Again, if I right click on in new windows/tab the page links work perfectly.

    Any ideas/suggestions welcome 🙂

    @mdrabble

    Participant

    I found and added this code to my functions.php within my theme folder – this allows you to sort the members by lastname.

    function alphabetize_by_last_name( $bp_user_query ) {
        if ( 'alphabetical' == $bp_user_query->query_vars['type'] )
            $bp_user_query->uid_clauses['orderby'] = "ORDER BY substring_index(u.display_name, ' ', -1)";
    }
    add_action ( 'bp_pre_user_query', 'alphabetize_by_last_name' );

    I then created a custom page template within my theme and pasted the membersloop.php code into that page and made some formatting changes as I only wanted it to affect this one page.

    On the line:
    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>

    I added ‘&populate_extras&type=alphabetical’

    so the line now shows as:
    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) . '&populate_extras&type=alphabetical' ) ) : ?>

    Hope that helps.

    @mdrabble

    Participant

    Ok, all working but how can i Get members-loop to sort on the last name? or better still, show username by last name, first name

    Any hints, clues, pointers welcome 🙂

    @mdrabble

    Participant

    Sorted…… found mycustom_ids function and membersloop

    Just need to sort how to display the details.

    Happy Days

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