Plugin / BuddyPig

Description

Description

BuddyPig is a game meant to help BuddyPress group members get to know each other better. It was built during a hack day at Automattic. Since we’re a distributed company, it’s not uncommon to go months without talking to certain colleagues. We came up with BuddyPig as a fun way to work around that.

PIG, in case you’re curious, is an acronym for Personal Information Game.

To use it you’ll have to write a small plugin to create questions and choose the BuddyPress group you’d like to use. PIG is very hook-able, so there’s lots of other stuff you can customize if you’re so inclined. We’ll include an example plugin to setup PIG below.

PIG requires BuddyPress and its Activity Streams feature to be running. It also requires PHP 5.3, which is slightly higher than the default requirement for WordPress.

Example setup

You have to tell PIG what profile items to use and how to ask the questions. We gave you a function called pig_register_question() to do just that. By default, pig_register_question() takes 2 arguments, the BuddyPress profile field name and a format to use to ask the question. Here’s an example:

pig_register_question( 'Address', 'Where does %s live?' );

You’ll notice the %s in the question format, which is where we drop in the user’s name that the question is about. If you’ve written PHP before, you may recognize this syntax from the sprintf() function, which is what is used behind the scenes.

You’ll also have to tell PIG what BuddyPress group to use, which can be done with pig_set_group() by passing the group’s ID. Here’s an example:

pig_set_group( 1 );

pig_register_question() can take two additional arguments.  The first one tells PIG whether to make the name possessive when it asks the question.  For example, "Where was Beau born?" would not be possessive, but "Where is Beau's house?" would be.  If you want PIG to make the name possessive, you can add `true` as the third argument, like this:

pig_register_question( 'Address', 'Where is %s house?', true );

The last optional argument is a callback. PIG can format answers for you before displaying them. One use case of this is deduplicating multiple phrases that mean the same thing, like “United States” and “USA”. If you use this callback, you must also make sure the function exists for PIG to call. Here’s an example:

pig_register_question( 'Address', 'Where is %s house?', 'a8c_dedupe_countries' );
function a8c_pig_dedupe_countries( $country ) {
    $usa_versions = array( 'US', 'USA', 'United States', 'U.S.A', 'U.S.', 'America', 'United States of America' );
    $uk_versions = array( 'UK', 'U.K.', 'United Kingdom' );
    foreach ( $usa_versions as $usa_version ) {
        if ( strtolower( $country ) == strtolower( $usa_version ) )
            return 'United States';
    }

    foreach ( $uk_versions as $uk_version ) {
        if ( strtolower( $country ) == strtolower( $uk_version ) )
            return 'United Kingdom';
    }

    return $country;
}

You can put these setup calls into your own plugin and activate it just like any other. If you insist, you could also put them into your theme’s functions.php file. To make sure they’re loaded after PIG is setup, you can hook them to the pig_loaded action.

Ratings

3
2 reviews

Rating breakdown

Details Information

Version

1.1.2

First Released

13 Aug, 2012

Total Downloads

2,649

Wordpress Version

3.4 or higher

Tested up to:

3.4.2

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.