BuddyDev

Search

[Resolved] limit friendship

  • Participant
    Level: Master
    Posts: 285
    evillizard on #19470
    This reply has been marked as private.
  • Participant
    Level: Master
    Posts: 285
    evillizard on #19487
    This reply has been marked as private.
  • Participant
    Level: Master
    Posts: 285
    evillizard on #19489
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #19497
    This reply has been marked as private.
  • Participant
    Level: Master
    Posts: 285
    evillizard on #19667

    this No. of Friends & Friendship Request Sent & Received ..in this pic https://i.postimg.cc/kggWrLsK/msg-3-not-work.png

    i dunno but doesnt it mean ..if a user sends.. then the friendship count would automaticcally increase by 1 friend? whether or not the reciever of the request chooses to accept the request or not? ..well it does not work: https://i.postimg.cc/fWHw2FV6/friendsss-screnshot-counf.png .. i sent a request to that dummy account .. but no friends count increased.


    i basically want to speed adding of the new recruits up .. i.e one the recruiter(the one who invited) sends friend request ..the friends count would automatically increase … wether or not the reciever of the request chooses to accept the request or not .. – since the friendship is already limited..then no need to wait for acceptance of requests.

    or is there a code to automatically accept friend requests? .. a code i could add to bp-custom.php?

    ………
    …..
    ========

    another thing is most of this messages: https://i.postimg.cc/yYPry4WZ/msgg-1-nt-work.png are not showing … dunno why .. but its not really important to me.. i just thought you should know..

  • Participant
    Level: Master
    Posts: 285
    evillizard on #19826

    Boss i knw you too busy, but
    are you able to reply now??

    The ones i stated above are still not working (no notice messages are showing)

    “duration of time user can send friend request” is also not working when i set it to 30,000000

    Does it hav a limit?..because i want it to be on forever? To make users only be able to send just 1 friend request forever
    ..

    If you are able to reply..pls do

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #19827

    Hi @evillizard

    1. Please do not use comma. Also, why do you need to set it to 30000000. Do you know the value is for 57 years duration?

    If you want to test it set a smaller time? It works. Let me assist you with other configuration to show how it works.

    Now for your questions:

    This No. of Friends & Friendship Request Sent & Received
    https://i.postimg.cc/kggWrLsK/msg-3-not-work.png

    i dunno but doesnt it mean ..if a user sends.. then the friendship count would automaticcally increase by 1 friend?

    No. Unless a user confirms the friendship, the count is not increased. That’s why you have the option to include requests in the count.

    basically want to speed adding of the new recruits up .. i.e one the recruiter(the one who invited) sends friend request ..the friends count would automatically increase … wether or not the reciever of the request chooses to accept the request or not .. – since the friendship is already limited..then no need to wait for acceptance of requests.

    Sorry, you are mistaken about this plugin then. It does not automatically confirm friends. The involved user need to confirm their friendship as normal. The plugin restricts.

    It is your choice to use the friends count or the friends count+request count as restriction.

    Please allow me to look a bit more about your situation and post back in the evening.

    Thank you
    Brajesh

  • Participant
    Level: Master
    Posts: 285
    evillizard on #19830

    Ok, boss i would wait.

    1- i knw i 30000000 is over 50 years

    2 i know it works when i set it to 30mins.

    3 i want to now if it could be on forever.. Each user should only be able to send just the set amount for friend request forever.. For example.. A user should only send just 1 friend request for ever ( no time duration) jst for ever.. Till i turn it off

    4 if number 3. Can not be done, then what is the highest time period i can set??
    ….

    5- ok, it does not automatically accept friend request .. So i set it to count by request, But their is no request count.. I cant find any where to view the request count?? .. I can only see the request on notifications..

    But cant find any count increasing or decreasing when i test to send request from dummy accts

    Or could it be my theme problem i use kelly theme.. Or maybe its cos i use buddypress noveau? ..could it be why im not seeing the notices aswell?

    Ild wait till evening for your response


    -happy new year btw

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #19838

    Hi there,
    Happy New Year.

    1. In your case, since you only need to limit the number of requests a person can send, Please only enable “Restrict who can add friend?” and disable all other settings.

    We only want to restrict request sending.

    Now, You can put this in bp-custom.php

    
    
    /**
     * Restrict sending request.
     *
     * @param bool $is_valid is valid request.
     * @param int $user_id sender user.
     *
     * @return bool
     */
    function buddydev_custom_restrict_sending_friendship_request( $is_valid, $user_id ) {
    
    	// If a user has these many friends, they won't be able to send new request.
    	$limit_on_friends_count = 1;
    
    	// If a user has specified number of friends, can not send new request.
    	if ( friends_get_friend_count_for_user( $user_id ) >= $limit_on_friends_count ) {
    		return false;
    	}
    
    	// for sent request count.
    	global $wpdb;
    	$bp = buddypress();
    
    	$sent_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT('*') FROM {$bp->friends->table_name} WHERE initiator_user_id = %d", $user_id ) );
    
    	// this is the maximum number of request a user can send
    	// it includes accepted friendship(sent by the user too).
    	$allowed_request_count = 1;// change it if you need.
    	if ( $sent_count >= $allowed_request_count ) {
    		return false;
    	}
    
    	return $is_valid;
    }
    
    add_filter( 'bpf_restrictions_user_is_valid_sender', 'buddydev_custom_restrict_sending_friendship_request', 10, 2 );
    
    

    This will solve your issue of the restriction and you will not need to make auto friends. Please update the values as you need.

    By default, BuddyPress does not list sent friendship request. We implemented in our theme(Community Builder) but most other theme won’t have this.

    We are going to release CB2 in next 1-2 week(it has been going on a overhaul for months) and we are putting a free version for our members too. You can give it a try and see if it suits you then.

    Thank you
    Brajesh

  • Participant
    Level: Master
    Posts: 285
    evillizard on #19867
     // If a user has specified number of friends, can not send new request.
            if ( friends_get_friend_count_for_user( $user_id ) >= $limit_on_friends_count ) {
                    return false;
            } 

    – it gives
    #Syntax error, unexpected ‘;’#

    And gives 505 error when i try to load site

The topic ‘ [Resolved] limit friendship’ is closed to new replies.

This topic is: resolved