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.

59 thoughts on “New BuddyPress plugin: Invite Anyone”

  1. 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.

  2. @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.

  3. 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

  4. 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 😀

  5. 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).

  6. 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() )
    if ( bp_group_is_admin() || bp_group_is_mod() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id) )

    Good luck!

  7. 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

  8. 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.

  9. 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!

  10. 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.

  11. 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!


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

  13. 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.

  14. 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.

  15. 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.

  16. 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?

  17. 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?

  18. 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.

  19. 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!

  20. @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?

  21. 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.

  22. 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.

  23. 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!

  24. 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?

  25. 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?

  26. 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.

  27. 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?

  28. 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;
    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!

  29. 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

  30. 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.

  31. 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.

  32. 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!

  33. 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!

  34. 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 🙂

  35. 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 😉

  36. 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!

  37. 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

  38. 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.

  39. 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.

  40. 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. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

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