BuddyDev

Search

Settings BP Private Message Rate Limiter based on user role

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #13208

    Hi Brajesh,

    Hope you are good.
    I am using your BP Private Message Rate Limiter to limit messages sending per month depending to membership levels.
    I have tried to use your method=> http://bit.ly/2GtroRg
    Like that:

    add_filter( 'bp_rate_limit_pm_count', 'devb_custom_private_message_limit_count', 10, 2 );
    function devb_custom_private_message_limit_count( $count, $user_id ) {
     
    if( ! $user_id )
    $user_id = get_current_user_id ();
     
    if( user_can( $user_id, 'create_users' ) ) //admin
    $count = 500;
    elseif( user_can( $user_id, 'pmpro_role_14' ) )
    $count = 2; //for player free trial
    elseif( user_can( $user_id, 'pmpro_role_13' ) )
    $count = 2; //for agent free trial
    elseif( user_can( $user_id, 'pmpro_role_2' ) )
    $count = 3; //for player rookie
    elseif( user_can( $user_id, 'pmpro_role_3' ) )
    $count = 5; //for player elite
    elseif( user_can( $user_id, 'pmpro_role_4' ) )
    $count = 10; //for agent starter
    elseif( user_can( $user_id, 'pmpro_role_5' ) )
    $count = 20; //for Agent elite
    elseif( user_can( $user_id, 'pmpro_role_6' ) )
    $count = 500; //for Agency
    elseif( user_can( $user_id, 'pmpro_role_7' ) )
    $count = 500; //for Scout
    elseif( user_can( $user_id, 'pmpro_role_10' ) )
    $count = 5; //for + 5 messages
    elseif( user_can( $user_id, 'pmpro_role_11' ) )
    $count = 20; //for + 20 messages
    
     
    return $count;
    }
    add_filter( 'bp_rate_limit_pm_throttle_duration', 'devb_custom_private_message_throttle_duration', 10, 2 );
     
    function devb_custom_private_message_throttle_duration( $duration, $user_id ) {
     
    if( ! $user_id )
    $user_id = get_current_user_id ();
     
    if( user_can( $user_id, 'create_users' ) ) //admin
    $duration = 2;// how many mins
    elseif( user_can( $user_id, 'pmpro_role_14' ) )
    $duration = 43800; //for player free trial
    elseif( user_can( $user_id, 'pmpro_role_2' ) )
    $duration = 43800; //for player rookie
    elseif( user_can( $user_id, 'pmpro_role_3' ) )
    $duration = 43800; //for player elite
    elseif( user_can( $user_id, 'pmpro_role_4' ) )
    $duration = 43800; //for agent starter
    elseif( user_can( $user_id, 'pmpro_role_5' ) )
    $duration = 43800; //for agent elite
    elseif( user_can( $user_id, 'pmpro_role_6' ) )
    $duration = 43800; //for Agency
    elseif( user_can( $user_id, 'pmpro_role_7' ) )
    $duration = 43800; //for Scout
    elseif( user_can( $user_id, 'pmpro_role_10' ) )
    $duration = 43800; //for + 5 messages
    elseif( user_can( $user_id, 'pmpro_role_11' ) )
    $duration = 43800; //for + 20 messages
    elseif( user_can( $user_id, 'pmpro_role_13' ) )
    $duration = 43800; //for agent free trial
     
    return $duration;
     
    }
    
    

    Unfortunatly it doesn’t work like i want because users can send messages as long as they don’t leave the window of the mailing box.
    The private message button become hidden only after the user logout then login.
    Could you help me please?

    Beuza

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #13221

    Hi Beuza,
    Sorry for the delayed reply.

    Are you using any 3rd party plugin for sending messages or is it core BuddyPress?

    Also, are you referring to New Message or new Replies?

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Beuza on #13244

    Hello Brajesh,

    I can not say it’s a plugin but there is a 1-to-1 chat feature built into the theme. But it made me malfunction while the feature was disabled.

    Im referring to new message.

    Beuza

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #13251

    Hi Beuza,
    I am going to test it again today and will report back.

    Thank you
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved