Skip to content


New BuddyPress plugin: Invite Anyone

In my view, the most powerful feature of BuddyPress – the feature that powers the core goal of the CUNY Academic Commons, that of collaboration – is groups. By default, BuddyPress only lets you invite other members of the community to your group if you and the member are already friends within BuddyPress. In some communities, this feature probably prevents a lot of spam. But in other communities, like the one here at the Commons, the friendship requirement adds a sometimes inconvenient extra step to the process of getting a productive group up and running.

Invite Anyone in action

Invite Anyone in action

This new plugin, Invite Anyone, does just what its name claims: it alters the group invitation process to allow group creators and administrators to invite anyone from their BuddyPress installation, not just their friends.

Like so often happens, though, solving this one problem made another one pop up: Scrolling through a list of your friends to find potential invitees is one thing, but scrolling through a list of every member of the site is another thing entirely. Most communities, including the CUNY Academic Commons, will simply have too many members. To make things easier, I’ve taken the autosuggest feature from the Compose Message screen in BuddyPress and retooled it to work on the Send Invites screen as well. Start typing the name of the user you’d like to invite, and with each letter you type, BuddyPress will make better and better suggestions as to who you mean. Just hit enter or click to add the suggested user to the invited list.

Download the plugin here. As the plugin is built using the BP Group Extension API, you’ll need at least BP 1.1.

After I’ve done a bit more testing with our custom theme here on the Commons, I’ll activate the plugin on this site, so that members of the Commons community can take advantage of the new feature.

A technical note: I tested the plugin in a variety of different environments (different browsers, different themes, different servers) and stumbled upon a few issues, in particular with the autosuggest AJAX in Chrome for Mac. If you find similar issues, or have any other feedback, please leave a comment.

Posted in Plugins and Extensions.

Tagged with , , , , , .

5 Tweets


64 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Bowe Frankema says

    Simply amazing and just what I needed! Thank you very much!

  2. Ray says

    Boone, you’ve done it again!
    Taken an idea I’ve had lingering in my head and implemented it!

    Will test this and let you know.

  3. Avatar of Joseph Ugoretz Joseph Ugoretz says

    Wow this is great and so needed! Yet another thing lighting a fire under me to get the BP upgrade done in the New Year. Thanks, Boone!

  4. Avatar of Matthew K. Gold Matthew K. Gold says

    Brilliant work, Boone — your incorporation of the search feature from the messaging interface was a great stroke. Thanks so much for this.

  5. bpisimone says

    Just great!

    Email invitations?

  6. Avatar of Boone Gorges Boone Gorges says

    @bpisimone – If by “Email invitations?” you are suggesting that I add the ability to send invitations to people who aren’t yet members of the site (by entering their email addresses), the answer is yes, I am going to add this functionality in the future.

  7. Mans says

    Wont work for me – I get this when I try to activate;

    Warning: require(/home/skolbloggen/wp-content/plugins/bp-invite-anyone/invite-anyone/invite-anyone-cssjs.php) [function.require]: failed to open stream: No such file or directory in /home/skolbloggen/wp-content/plugins/invite-anyone/invite-anyone.php on line 322

    Fatal error: require() [function.require]: Failed opening required ‘/home/skolbloggen/wp-content/plugins/bp-invite-anyone/invite-anyone/invite-anyone-cssjs.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in /home/skolbloggen/wp-content/plugins/invite-anyone/invite-anyone.php on line 322

  8. Avatar of Boone Gorges Boone Gorges says

    Mans – I just realized this problem about 10 minutes ago! See the solution here: http://buddypress.org/forums/topic/invite-anyone

  9. nessie says

    Thank you very much for your plugin !
    I experiment issues with wordpress mu 2.8.4a and bp 1.1.3 : the invitations don’t appear on the invite-anyone-invite-list (the “Select people to invite.” message disappear but the list is blank)… I’d be very grateful if I knew how to fix this bug :D

  10. Avatar of Boone Gorges Boone Gorges says

    Hi nessie -

    Is it possible that you’re attempting to invite members to a group of which you are not the admin? BP displays weird behavior when this happens.

    I’ve updated the trunk version of my plugin to remove the “Send Invites” button for members of the group who are not admins or mods of the group. If you’d like other group members to have invitation power as well, go to line 90 and add || bp_group_is_member() to the conditional statement, right after bp_group_is_mod(). In the future I’ll make this a group admin option (ie whether to allow regular group members to invite others).

  11. Avatar of Boone Gorges Boone Gorges says

    nessie – Just realized that bp_group_is_member() won’t work. If you want all group members to have access to the Send Invites screen, replace
    if ( bp_group_is_admin() || bp_group_is_mod() )
    with
    if ( bp_group_is_admin() || bp_group_is_mod() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id) )

    Good luck!

  12. brian says

    Hi – Just tried to upload and activate; got this error message:
    Plugin could not be activated because it triggered a fatal error.

    Fatal error: Class ‘BP_Group_Extension’ not found in /home/glrfinfo/public_html/NetworkNow/wp-content/plugins/invite-anyone/invite-anyone.php on line 17

  13. Avatar of Boone Gorges Boone Gorges says

    Hi Brian. Are you running BP 1.1 or higher? This plugin won’t work for earlier versions of BuddyPress.

  14. brian says

    Hi Boone – Ahhh, sorry to have bothered you. I’m running BP 1.03.

    Here’s a sample of our public site – http://miamirowingfestival.glrf.info – that’s as far as you can go since we’re a membership site

    Unfortunately, I don’t know how to code the php in bp-custom.php so to tailor the bp site to our look, I have to hack the core in each installation, adding and changing all the lines of code. The result is I hold off on bp upgrades. I plan to upload 1.2 after it gets released, and settled a bit.

    Then I’ll give your plugin a go.

  15. Avatar of Boone Gorges Boone Gorges says

    Hi Brian – Sorry about the compatibility issue – Andy Peatling included the Group Extension API for the first time in BP 1.1, and it would’ve been very messy to make the plugin work for earlier versions of BP.

    I know how you feel about the core hacks. I definitely recommend learning about how BuddyPress hooks work. The more I learn about them myself, the fewer core hacks I have to resort to, which means much, much easier upgradability. Good luck!

  16. Ray says

    Hey Boone,

    Just tried out the latest version.

    Is there a reason why you’re using inline CSS in the footer, instead of an external stylesheet in the head?

    Also, it would be nice if the CSS only showed up on the pages it is needed, like your javascript is.

  17. Avatar of Boone Gorges Boone Gorges says

    Hi Ray,

    The only reason I did the CSS like that is because I was figuring out how it worked :) I will fix it to be the right way (external sheet called in the head and only on necessary pages) next time I update the plugin.

    Thanks for calling me out!

    Boone

  18. simon says

    Any chance of a “select All” option. I have 5,000 members and often want to invite them all, which is a nightmare!

  19. Avatar of Boone Gorges Boone Gorges says

    Hi Simon,

    A “select all” button is an interesting idea. I’d also have to add a function so that admins could turn off the select all button, as I’m sure you don’t want all 5,000 members of your community to be able to invite everyone too! Maybe I’ll look at it for the next version.

  20. Erich73 says

    Hey Boone,

    many thanks for writing this plugin !

    Is your plugin able to solve the following ticket ?

    http://trac.buddypress.org/ticket/1498

    Thanks again !

  21. Erich73 says

    you might also want to check out this great plugin:

    http://danpolant.com/bp-group-control

  22. Deryk says

    Is it possible to allow this plugin to only work for admins (or moderators if they exist) and not allow regular users to do this? I’ll be working with a community of over 5000 and this could get abused, but would be invaluable for certain moderators.

  23. Avatar of Boone Gorges Boone Gorges says

    Deryk, that’s a great idea for future enhancement. For now, you can pretty easily implement it yourself. Two changes in invite-anyone.php:

    1. Replace if ( bp_group_is_admin() || bp_group_is_mod() ) on line 90 with if ( is_site_admin() )
    2. Fine bp_core_remove_subnav_item( $bp->groups->slug, 'send-invites' ); on line 362. Paste the following on the line immediately before that line: if ( is_site_admin() )

    I have not tested this (I’m a busy boy!) but these should work without a hitch. I’ll make it a menu-level thing in the next version.

  24. AntonRSA says

    Hi Boone, sorry to bother you again. I’ve got version 0.2 installed of this plugin on my bp 1.1.3 and wpmu 2.86.

    There’s a bug on this plugin. Anyone can see the option “invite members” of the group if they are logged in or logged out. I noticed this when one of the groups were indexed by google and I followed it to the invite members screen without being logged in or being a member of the group. is there an update for this plugin? Is there anything I can setup in the plugin so that it’s only visible to group admin members?

  25. Avatar of Boone Gorges Boone Gorges says

    I can’t reproduce your problem, Anton. On the CUNY Academic Commons, as well as all my test instances with your setup, the link works correctly: it only shows for site admins and mods. See lines 90-93 of invite-anyone.php.

    Are other admin-only things like the Admin link showing up for non-members as well?

  26. Avatar of Boone Gorges Boone Gorges says

    Anton- I was just looking at the code again and I see a possible cause. Try commenting out line 19 that says var $enable_nav_item = true;. That should in theory be overridden by the stuff later, but maybe it’s causing a problem in your case.

  27. Tim says

    Hey Boone!
    I’m trying to use ‘invite anyone’ plugin with buddypress 1.2 RC and a single user WP installation (not MU) version 2.9.1, but I can’t get it to work! :S
    Please check this screenshot: http://www.venturelabtwente.com/wp-content/uploads/2010/02/invite-anyone-problem.jpg.
    As you can see, it keeps on copying!! And part to select the users also doesn’t seem to work…
    Any ideas? Thanks for your help!

  28. Avatar of Boone Gorges Boone Gorges says

    Hi Tim,

    This is an issue with the new bp-default template shipped with BP 1.2 and my plugin. I haven’t had a chance yet to make it work right with BP 1.2, but it’s on my list of things to do next week. Watch the repo for a new version of Invite Anyone that will work properly with bp-default!

  29. Tim says

    Thanks for the reply!
    Great! Looking forward to it!

  30. AntonRSA says

    @boone – I’ve commented out line 19 but it still does the same. It still appears on the group menu even if you are not a member. When I deactivate your plugin, the default bp group invite doesn’t send out emails to the recipients. I had to implement some code so that only registered users can view groups with your plugin activated. Any thoughts on this?

  31. Avatar of Boone Gorges Boone Gorges says

    Hi Anton,

    Sorry for the troubles you’re having with the plugin.

    You say that with the plugin deactivated, invite emails don’t get sent out. Do the invites themselves work within BP? That is, do invited members get notifications, and when they go to their group invites page, do they see them? Or is it a problem with emails only? I’d be very surprised if it has anything to do with this plugin, as the plugin doesn’t touch anything in the core code or the database that would cause problems like this. Have you tried troubleshooting that issue by disabling other plugins?

    As for the visibility thing: again, I’m stymied, as it works on my installation. Do you have any other group extensions installed? (Group Documents, etc) I’d be curious if the visibility settings are working correctly for those extensions? Again, trying to narrow down whether it’s a problem with my code or whether there’s something peculiar about your setup that’s making group extensions not work quite right.

  32. AntonRSA says

    Thanks Boone for the reply. Yes all the other functions work and i’m not using any other group functions except your other one “subscribe to comments”.

    I really like the plugin and don’t want to lose the functionality of it. I activated again and thought I could add an if statement surrounding the whole plugin.. if(!is_user_logged_in() { }
    but it gives me the error – unkwoun function is_user_logged… what can I do so that only users that are logged in can view the menu item? That will not be 100% but at least only members of the site will see the “Send Invites” option instead everyone.

  33. AntonRSA says

    Hey hey! I got it to not show the invite menu wrapped it around if(!$bp->loggedin_user->id)

  34. Avatar of Boone Gorges Boone Gorges says

    That’s great, Anton! Though it does suggest that there’s something in the core group extension code that it’s not working quite right. In any case, great job!

  35. AntonRSA says

    sorry to bug you again, I’ve got it working now that only members of the site can see the send invites option. What can I wrap around the “if statement” so that only members of the group can see that option?

    BTW – you build awesome plugins!

  36. Avatar of Boone Gorges Boone Gorges says

    Anton – Try if ( bp_group_is_member() )

  37. Ray says

    Hey Boone,

    Just testing this plugin again.

    If you do not select anyone in the “Invite Anyone” page, when you finish the group creation step, the template notice says “Group Invites sent” even though I did not send any invites.

    Anyway to change this message to a default “Your group has been created” message?

  38. Ray says

    In my previous message, I meant can we change the template notice message if no invites are sent, but keep the invites message if invites were made?

  39. Avatar of Boone Gorges Boone Gorges says

    Hi Ray,

    Great idea – just checked in version 0.3.1 with it implemented (turned out to be easy). Tell me if it’s working for you! (You’ll also noticed I moved the CSS into an external file like a good boy :) )

    Tim – if you’re following this comment thread, I’ve updated the plugin so that it should work with bp-default in BP 1.2.

  40. Ray says

    Hey Boone,

    Once again, you’re the man!
    Thanks for putting the CSS in an external file ;)

  41. AntonRSA says

    Boone, It doesn’t work. Seems I’ve got the luck. Where can I wrap that code you provided – if a member is part of the group?

  42. Avatar of Boone Gorges Boone Gorges says

    Hi Anton – yes, you do have the luck!

    Here’s how the enable_nav_item method should look if you only want group members and site admins to see it:

    function enable_nav_item() {
    global $bp;

    if ( bp_group_is_member() || is_site_admin() )
    return true;
    else
    return false;
    }

    But again, since the original code isn’t working right for you (which should show the menu item only to group admins/mods) then this probably won’t either. Let me know one way or another!

  43. Mark Schafer says

    Hey Boone – I’m getting 2 php warnings when the latest version of invite-anyone is activated and I visit blogs on my wpmu site. It seems to be blog template specific as I have at least one blog template that does not generate the warning. You can see it live at this link: http://pipp.ttacconnect.org/. I’ll probably disable the plugin by the end of the day so I’ll paste the error also:

    PHP Warning: in_array() [function.in-array]: Wrong datatype for second argument in /public_html/wp-content/plugins/invite-anyone/invite-anyone/invite-anyone-cssjs.php on line 6

    PHP Warning: in_array() [function.in-array]: Wrong datatype for second argument in /public_html/wp-content/plugins/invite-anyone/invite-anyone/invite-anyone-cssjs.php on line 44

  44. Avatar of Boone Gorges Boone Gorges says

    Hi Mark,

    Thanks for reporting the error. Are you having the problem on the blog where BuddyPress lives? (It looks like you’re not.) So here’s a quick fix: Go to invite-anyone.php and remove the line that says “Site Wide Only: true”. Deactivate the plugin, and reactivate it only on the main BP blog.

    I’ll look at fixing the error, but I’ll probably also remove the sitewide only requirement from the next version as well, as it doesn’t really make a lot of sense for this kind of plugin.

  45. Mark Schafer says

    Quick Fix works. Thanks! You’re correct – no original problem with the blog in BP. I didn’t know that the comments (between /* */ ) at the beginning of the plugin code are actively read. Interesting. Thanks again.

  46. Tim says

    Hi Boone!
    I was following the comment thread, but I missed my name :).
    Thanks for the update! Really great! It works now! But…

    Only one thing… could it be that ‘Or select members from the directory:’ and the grey block below this, only works when you have the friends component enabled?
    I’m afraid so :S. This is at least the case on my site…

    Probably not something you want right? I wasn’t planning to enable the friends component, but I would like to use your plugin. Maybe more people have the same situation?

    Looking forward to your reply!

  47. Tim says

    I gave it some thought, and I think I’ll just enable the friends component in bp, but maybe it’s still something you wanna think about; to give people the choice..

    Thanks again for updating! Great plugin!

  48. Avatar of Boone Gorges Boone Gorges says

    Tim – Great idea. I’ve implemented it in 0.3.2, just uploaded to the repo.

    Mark – I also removed the site wide only requirement in 0.3.2, and put a message in the readme suggesting that people activate it only on the BP blog. Doesn’t really solve the core problem, but will save some headaches for now :)

  49. Tim says

    Great!

  50. Ray says

    Boone,

    I experienced the wrong datatype problem today and fixed it with this:

    ` if (!isset($bp->action_variables))
    return false; `

    Put this right after global $bp in the invite_anyone_add_js() and invite_anyone_add_css() functions.

    It’s good that you removed the site-wide only option as well because I don’t think it’s needed except on the blog where BP is activated ;)

  51. AntonRSA says

    It didn’t work but will be upgrading to wpmu 2.9.1 and bp 1.2.1 in a couple of days and update your plugin. I’ve got it installed on another bp 1.2.1 site of mine and it works excellent!

    I fiddled to much with the core files and only realised this when it was too late :)

    I love your other plugins and just want to say thanks for support!

  52. Betty says

    this is a great plugin — thanks for sharing

  53. pankaj says

    I am using wp = bp with theme parallelus-salutation, i tried but it gives my admin screen blank (error)

  54. Greg Marriott says

    Love this plugin… especially the way it keeps track of invites and those who have accepted, this could form the basis of a “recruitment” plugin, almost like a membership affiliate system if you could “link each parentID with a downline childID” and NOT allow the user to delete the list of users who have signed up… In a “paid” subscription site (I use WPMUDEV Membership Pro), it would be nice to pay the recruiter a commission on a successful sign up…also to be able to see a “tree” of who recruited who, would be incredible and I am willing to pay for such enhancements. GREAT WORK

  55. Jonathan says

    Hi Boone. Thanks for a great plugin. One question: I’m using this in a private community with WP-Members and a custom setup which allows logged out visitors to login or register but not see any content. Is there a way to customize the code or create a custom landing page for your plugin? At this point my users just see 404 pages or a prompt to log in but without the custom code originally in the URL which identifies them as having been invited to a specific group. Also, are there issues with hidden groups and the plugin? Much appreciated.

  56. Avatar of Boone Gorges Boone Gorges says

    Hi Jonathan. The fastest fix for your WP-Members issue is probably to whitelist URLs of the form /register/accept-invitation/* (I assume that your plugin allows you to create whitelisted URLs for non-members).

    I’m not sure what you mean by “issues with hidden groups and the plugin”. I don’t know of any existing problems.

  57. Jonathan says

    I ended up ditching WP-Members and the problem went away. Thanks.

  58. Jaemaz says

    Fantastic plugin– many thanks. Most of the functionality is working, but I am unable to access the plugin settings.

    I am running a multisite installation, and the primary blog is the main front-facing site wwww.placeholder.com, and the BP installation where I have the plugin activated is at community.placeholder.com. Within this configuration the “Invite Anyone” settings are not available anywhere, (I know they should be in the network dashboard). When I click on “Settings” next to the plugin description in the plugin list in the Community dashboard it tries to take me to the page where the settings *should* be (community.placeholder.com/wp-admin/network/admin.php?page=invite-anyone), but then presents a message that says “You do not have sufficient permissions to access this page.”

    Any suggestions or workarounds? Thanks. :)

Continuing the Discussion

  1. Teleogistic / New BuddyPress plugin: Invite Anyone linked to this post on December 18, 2009

    [...] more about it, and download the plugin, at the CUNY Academic Commons Dev blog. The New BuddyPress plugin: Invite Anyone by Boone Gorges, unless otherwise expressly stated, is [...]



Some HTML is OK

or, reply to this post via trackback.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image

Additional comments powered by BackType



css.php