Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25323
    Brajesh Singh on in reply to: Intranet Site to Create Logins #20071

    Hi Karla,
    Thank you for using the plugin. The plugin serves a different purpose. It activates and logs in user as soon as you register from front end registration page(which seems to be not used in your case).

    There is a solution but I need to know do you want to login user so that they are shown in the members directory?
    If you do not ask user to confirm their account(at the time of registration in admin), their account get already activated.

    Please let me know and I will assist.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Hi Richard,
    Thank you.

    I am looking forward to your feedback tomorrow.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Sure,
    Here is an example using role.

    I have broken it into 2 functions for defining role based limit and then getting user specific limits.

    After that, there are two functions attached to filters. All you need to modify is the first function that supplies role based limit.

    
    
    /**
     * Get the applicable limit for the given role.
     *
     * @param string $role role name.
     *
     * @return array
     */
    function buddydev_custom_get_role_based_activity_limit( $role ) {
    
    	// duration- in minutes
    	// limit - how many in that duration
    	$limits = array(
    		'administrator' => array(
    			'duration' => 1440,
    			'limit'    => 0,
    		),
    		'editor'        => array(
    			'duration' => 60,
    			'limit'    => 10,
    		),
    		'author'        => array(
    			'duration' => 60,
    			'limit'    => 5,
    		),
    		'contributor'   => array(
    			'duration' => 1440,
    			'limit'    => 20,
    		),
    		'subscriber'    => array(
    			'duration' => 1440,
    			'limit'    => 10,
    		),
    	);
    
    	$default = array(
    		'duration' => get_option( 'bp_rate_limit_activity_throttle_duration', 5 ),
    		'limit'    => get_option( 'bp_rate_limit_activity_count', 5 ),
    	);
    
    	return isset( $limits[ $role ] ) ? $limits[ $role ] : $default;
    }
    
    /**
     * Get the limit/duration for the given user.
     *
     * @param int $user_id user id.
     *
     * @return array
     */
    function buddydev_custom_get_user_activity_limits( $user_id ) {
    	// since a user may have more than 1 role, which of the limit should we use? I will go with the highest allowed.
    	$allowed = array(
    		'duration' => 0,
    		'limit'    => - 1,
    	);
    
    	$user    = get_user_by( 'id', $user_id );
    
    	if ( ! $user ) {
    		return $allowed;
    	}
    
    	foreach ( $user->roles as $role ) {
    		$limit = buddydev_custom_get_role_based_activity_limit( $role );
    
    		if ( $limit['limit'] > $allowed['limit'] ) {
    			$allowed = $limit;
    		}
    	}
    
    	return $allowed;
    }
    
    /**
     * Filter activity count.
     *
     * @param int $limit limit applied for the specified duration.
     * @param int $user_id user id.
     *
     * @return mixed
     */
    function buddydev_custom_filter_ra_activity_count( $limit, $user_id ) {
    
    	$config = buddydev_custom_get_user_activity_limits( $user_id );
    
    	return isset( $config['limit'] ) ? $config['limit'] : $limit;
    }
    
    add_filter( 'bp_rate_limit_activity_count', 'buddydev_custom_filter_ra_activity_count', 10, 2 );
    
    /**
     * Filter duration
     *
     * @param int $duration duration in minute
     * @param int $user_id user id.
     *
     * @return int
     */
    function buddydev_custom_filter_ra_activity_throttle_duration( $duration, $user_id ) {
    
    	$config = buddydev_custom_get_user_activity_limits( $user_id );
    
    	return isset( $config['duration'] ) ? $config['duration'] : $duration;
    }
    
    add_filter( 'bp_rate_limit_activity_throttle_duration', 'buddydev_custom_filter_ra_activity_throttle_duration', 10, 2 );
    
    

    Hope that helps.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Hi,
    I am sorry but I am unable to understand the question. Please help me understand it a bit better and I will assist.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Hi Daniel,
    Thank you for asking. The plugin was completed but we did not release it. If you can use it from github, I can push it there(It’s on our bitbucket private repo for now).

    I will find some time this week to create a blog post and documentation for this plugin and publish it.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Hi Richard,
    Please do not use above snippet. It won’t work.

    Will it be good enough If I can put an example using roles or member types(please let me know which one you will prefer)?

    Regards
    BRajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Hi Richard,
    Thank you for the details.
    I am glad it is resolved. Always happy to assist 🙂

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Hi Herve,
    The above code is correct and It will work with current BuddyPress unless you have changed the field ids or some other code is interfering with it.

    Also, if you are using BP Nouveau template pack, It can affect the above query(The Nouveau template also filters on ‘bp_pre_user_query_construct’ and ” ).

    My suggestion will be to switch to BP Legacy and try.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323

    Hi,
    Thank you for asking the question and my apologies for the delayed reply.

    We do not suggest moving sub tabs from one tab to another. BuddyPress as well as most of the plugins we have tested do not support this kind of movements. Most of the sub tab functionality are tied to their current component(tab is component).

    Technically, you can move the sub tabs but the links will break as the original sub tab callbacks will not be able to handle the new url/action(the reason is almost all handler uses bp_is_current_component() with hardcoded component id and that makes it inflexible).

    Hope that clarifies.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25323
    Brajesh Singh on in reply to: buddydev simple user contest plugin. #20044

    Hi @evillizard
    Thank you for the suggestion.

    At the moment, we are unable to say if we will be able to do it or not. If time permits, we will be glad to do it in next few months.

    Thank you
    Brajesh