Skip to:
Content
Pages
Categories
Search
Top
Bottom

function get_friend_user_ids() question


  • StuntDevil007
    Participant

    @stuntdevil007

    I am looking through the core files (as a learning tool) and I for the life of me cannot find how being on the friend requests page changes the function argument from false to true for this method:

    Being on the requests page somehow changes the $friend_requests_only var to TRUE. How? I searched everywhere and I dont see it happening.

    	public static function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
    		global $wpdb;
    
    		if ( !empty( $friend_requests_only ) ) {
    			$oc_sql = 'AND is_confirmed = 0';
    			$friend_sql = $wpdb->prepare( " WHERE friend_user_id = %d", $user_id );
    		} else {
    			$oc_sql = 'AND is_confirmed = 1';
    			$friend_sql = $wpdb->prepare( " WHERE (initiator_user_id = %d OR friend_user_id = %d)", $user_id, $user_id );
    		}
    
    		$friends = $wpdb->get_results( "SELECT friend_user_id, initiator_user_id FROM {$wpdb->prefix}ms_friends {$friend_sql} {$oc_sql} ORDER BY date_created DESC" );
    		$fids = array();
    
    		for ( $i = 0, $count = count( $friends ); $i < $count; ++$i ) {
    			if ( !empty( $assoc_arr ) ) {
    				$fids[] = array( 'user_id' => ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id );
    			} else {
    				$fids[] = ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id;
    			}
    		}
    
    		return $fids;
    	}

    I do see in the member functions a check is done to test if the requests page is active:

    	// User filtering
    	if ( bp_is_user_friends() && ! bp_is_user_friend_requests() ) {
    		$user_id = bp_displayed_user_id();
    	}

    however this only populates the $user_id var and should have no affect on the $friend_requests_only var above. Can someone clarify how this is done?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘function get_friend_user_ids() question’ is closed to new replies.
Skip to toolbar