Skip to:
Content
Pages
Categories
Search
Top
Bottom

tweaking friend function


  • phpman
    Participant

    @phpman

    Hi
    I intalled the lates wp + buddypress on my computer
    I am trying to disallow friendship between men and women
    in database the field man or woman is set in wp_bp_xprofile_data
    a lot of things are mixed in there
    the “man or woman” field is field_id = 2
    In order to do that I tried to tweak bp-friends-functions.php in two ways
    the first way wich is not good but works

    
    	$friendship = new BP_Friends_Friendship;
    
    	if ( (int) $friendship->is_confirmed )
    		return true;
    
    	$friendship->initiator_user_id = $initiator_userid;
    	$friendship->friend_user_id    = $friend_userid;
    	$friendship->is_confirmed      = 0;
    	$friendship->is_limited        = 0;
    	$friendship->date_created      = bp_core_current_time();
    /**------hommes femmes femmes hommes----------------------*/
    	if ( $initiator_userid == 1 OR $friend_userid == 6 OR $friend_userid == 11 OR $friend_userid == 12 OR $friend_userid == 13 OR $friend_userid == 14 OR $friend_userid == 15 OR $friend_userid == 16 OR $friend_userid == 17 OR $friend_userid == 18 OR $friend_userid == 19 OR $friend_userid == 20)
    		{ if ($friend_userid == 7 OR $friend_userid == 10 OR $friend_userid == 11 OR $friend_userid == 12 OR $friend_userid == 13 OR $friend_userid == 14 OR $friend_userid == 15 OR $friend_userid == 16 OR $friend_userid == 17 OR $friend_userid == 18 OR $friend_userid == 19 OR $friend_userid == 20 )
    			{ return false;
    			}
    		;}
    	elseif ($friend_userid == 7 OR $friend_userid == 10 OR $friend_userid == 11 OR $friend_userid == 12 OR $friend_userid == 13 OR $friend_userid == 14 OR $friend_userid == 15 OR $friend_userid == 16 OR $friend_userid == 17 OR $friend_userid == 18 OR $friend_userid == 19 OR $friend_userid == 20 )
    		{ if ($initiator_userid == 1 OR $friend_userid == 6 OR $friend_userid == 11 OR $friend_userid == 12 OR $friend_userid == 13 OR $friend_userid == 14 OR $friend_userid == 15 OR $friend_userid == 16 OR $friend_userid == 17 OR $friend_userid == 18 OR $friend_userid == 19 OR $friend_userid == 20)
    			{ return false;
    			}
    		;}
    
    	if ( $force_accept )
    		$friendship->is_confirmed = 1;
    
    

    and the better but non working way

    
    $champ_genre = 2;
    	$base = mysql_connect ('localhost', 'root', 'root') ;
    	mysql_select_db ('reseau', $base) ;
    // on extrait la donnée genre pour l'initiateur
    	$sql = 'SELECT value FROM wp_bp_xprofile_data WHERE field_id = 2 AND user_id =' .$initiator_userid. '';
    	$req = mysql_query($sql) or die('erreur SQL !'.$sql.'' .mysql_error());
    	$resultat = mysql_fetch_array($req);
    	mysql_free_result ($req);
    	mysql_close();
    	$genre_i = $resultat['genre'];
    // même chose pour l'ami
    	$base = mysql_connect ('localhost', 'root', 'root') ;
    	mysql_select_db ('reseau', $base) ;
    	$sql = 'SELECT value FROM wp_bp_xprofile_data WHERE field_id = 2 AND user_id =' .$friend_userid. '';
    	$req = mysql_query($sql) or die('erreur SQL !'.$sql.'' .mysql_error());
    	$resultat1 = mysql_fetch_array($req);
    	mysql_free_result ($req);
    	mysql_close();
    	$genre_f = $resultat1['genre'];
    // on compare
    if ($genre_i = 'homme' AND $genre_f = 'femme')
    return false;
    elseif ($genre_i = 'femme' AND $genre_f = 'homme')
    return false;
    /* fin du code*/
    

    My question is what went wrong in it? it didn’t change anything O_o
    I tried a lot of way
    sometimes all friendship request are blocked and sometimes all are allowed with the second method.

    Thx for ur support

Viewing 1 replies (of 1 total)

  • phpman
    Participant

    @phpman

    I know,
    in if I need ” == ” not ” = ”

    It works fine now 🙂
    I’m customizing it.

    Anyone can help me making it a plug-in?
    I’m new in wordpress and php

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