Category: BuddyPress

Hide Profile Field Groups in BuddyPress

This is a quick introduction to a new plugin I just released on WordPress called BuddyPress Conditional Field Groups. This pluginĀ enables site administrators to show/hide BuddyPress profile field groups to users based on user role.

The intended application is for sites with a diverse user base that may want to collect and display different sets of information based on the user type.

Here is a demo:

BCFG

 

Let me know if you have any questions or requests.

 

Determine if a User is Online in BuddyPress

Here is a quick function that I wrote to determine whether or not a BuddyPress user is online.

/**
 * Is the current user online
 * 
 * @param $user_id
 *
 * @return bool
 */
function sc_is_user_online( $user_id ) {
    $last_activity = strtotime( bp_get_user_last_activity( $user_id ) );
 
    if ( empty( $last_activity ) ) {
        return false;
    }
 
    // the activity timeframe is 15 minutes
    $activity_timeframe = 15 * MINUTE_IN_SECONDS;
    return ( time() - $last_activity <= $activity_timeframe );
}

The function bp_get_user_last_activity returns the time of the users last activity. Then all we have to do is see if that timestamp falls within the activity timeframe we have established.

That’s it! See I told you it was going to be quick. šŸ™‚

Create Groups in BuddyPress Programmatically

Let’s say that you that you are building a custom application with BuddyPress (like maybe this) and you had a need to programmatically create a BuddyPress group. Now there are ways to customize the BuddyPress group creation process that I will cover in a future post, but there is actually a very simple function that will do all the heavy lifting. So, without any further ado, I’d like to introduce you to groups_create_group(). Read more

Have You Heard of BuddyPress?

Last year I was working on a new membership feature for my church’s website (actually, I’m still working on it) that would help to facilitate interaction among the churchgoers throughout the week. Being a hard core developer, I rolled up my sleeves and started working through how I would handle discussions, notifications, user profiles, and the like. After spending a few weeks of weekends and eveningsĀ hacking on it I decided to check and see what kind of prebuilt solution for this kind of application might already exist (yes this is the problem with developers: code now – research later). Read more