Skip to content

Help me alpha test BuddyPress Forum Attachments

Now that bbPress is integrated into the Very Fabric of BuddyPress, there’s some demand for useful bbPress plugins to be ported over to BP. One of the most useful is _ck_’s excellent bb-attachments, which allows users to add attachments to their forum posts. I have spent a bit of time in the last few days porting it over to BP. If anyone out there is running a BP+bbPress setup (I think it should work in any recent version of BP, but I’ve only tested in BP 1.1) and would like to help me to test what is I think a functional BP version of the plugin, please do so. Here are the details.

  1. Download the plugin bb-attachments.php.zip
  2. Unzip and upload to your WPMU plugin directory. Activate it.
  3. You’ll have to make a few changes/additions to your theme files to make it work. In your BP theme directory, go to groups/single/forum/topic.php. On line 9, after the ‘template_notices’ hook, add
    <?php do_action( 'topic_page_load' ) ?>

    Next: After line 61, which reads

    <?php bp_the_topic_post_content() ?>

    insert the following line

    <?php do_action( 'bp_after_post_content' ); ?>

    Next: On line 26, replace

    <form action="<?php bp_forum_topic_action() ?>" method="post" id="forum-topic-form" class="standard-form">

    with

    <form action="<?php bp_forum_topic_action() ?>" method="post" id="forum-topic-form" class="standard-form" enctype="multipart/form-data">
  4. In the same theme directory, open edit.php and index.php. Find the <form> tags, as described in the last part of the previous step, and replace them with the alternative <form> tag (with the enctype specified)
  5. Follow steps 1 and 2 from here. Step 5 on that page (the “optional settings”) you can do as well, and those settings might take some tweaking for certain filetypes to be allowed.
  6. Start uploading!

A few caveats:

  • I have not tested any of the AWS abilities. It’s possible that they will still work, as the AWS functionality is more or less abstracted from the specific bbPress hooks.
  • Inline images are not yet supported. I’m working on it.
  • Things look a little bit ugly with the default BP 1.1 theme. I haven’t done much to make it pretty. I’m happy to take aesthetic suggestions, if you have any.

Thanks in advance for your help. Please leave any comments here in this post’s thread.

Related posts:

  1. Forum Attachments for BuddyPress
  2. New BuddyPress / bbPress plugin: Group Forum Subscription
  3. Upgrading from BuddyPress 1.0 to 1.1
  4. Group Forum Subscription for BuddyPress 1.1
  5. Displaying the BuddyPress admin bar in other applications

47 Comments

  1. Ray

    Hey Boone,

    Here’s a question that I’m sure will make you cringe!

    What if you’re using the regular bb Attachments plugin on bbPress and want to use this new plugin for BP 1.1 while keeping the old attachments from the old bbPress install?

    I haven’t tested your port of _ck_’s plugin yet — you say it should work with BP < 1.1 as well — but I will in due time!

    Posted on 14-Oct-09 at 12:06 pm | Permalink
  2. Ray

    Just tested on a deep-integrated BP-bbPress install (using BP 1.0.2).

    It’s not liking the undeclared bbPress functions like bb_number_format_i18n() and bb_get_current_user_info(), which makes sense because bbPress isn’t integrated into the WPMU/BP stack in BP < 1.1.

    I'm guessing it's probably not possible to get this working with BP < 1.1 without a lot of code refactoring.

    Posted on 14-Oct-09 at 4:11 pm | Permalink
  3. Ray

    Boone,

    Just wanted to say that Akismet ate my last comment on your blog.

    Automattic really doesn’t like me! :p

    Posted on 14-Oct-09 at 4:13 pm | Permalink
  4. Hey Ray,

    Yeah, your question does make me cringe a bit :) Actually, I don’t think that the problem is insurmountable. The structure of the bb-attachments table is exactly alike in both plugins, and they both save files in the same spot. There might be some trickiness relating to the different ways that forum paths work in bbPress standalone and in BP 1.1+, and I imagine that it would take some trickery (either in moving your files and tables around, or altering the plugin code) to get this piece of the puzzle in place. But definitely doable.

    I guess I’m not all that surprised to hear that there were conflicts in BP 1.0.2. I suppose that, when I said it might work, I wasn’t really thinking straight. Part of the reason the code was relatively easily portable to BP 1.1 is because so many of the bbPress functions are loaded by that version of BP. Since that’s not the case in earlier versions, it’s unsurprising to hear that it’s not functional. On the bright side, you can still use the bbPress interface and thus _ck_’s original and much awesomer version!

    Posted on 14-Oct-09 at 6:33 pm | Permalink
  5. It works well, if you are not trying to delete attached file. Than it shows 404. The link after deletion is:
    example.com/forum/topic.php?id=6#post-105
    As you can see, it’s not:
    example.com/groups/wordpress/forum/topic/sometitle/
    This part – “groups/wordpress/” – in after-deletion-url is missing.

    Posted on 23-Oct-09 at 6:23 am | Permalink
  6. And that might be a good idea to add file attachments on edit post page (when you are editing already published post in group forum).

    Posted on 23-Oct-09 at 6:31 am | Permalink
  7. Great catches, slaFFik. Both should be easy to fix. I won’t have access to a computer for a few days, but I’ll make the changes when I get back. At that time I’ll add the localization pack you mentioned – thanks again for that!

    Posted on 23-Oct-09 at 8:21 am | Permalink
  8. Deryk

    The plugin works fine I can upload images and download them again, but when I sign in as a different user, i see a broken image icon as well the download link is broken. I get the error ‘Sorry, download is restricted.’ on a blank page as well as a popup. I’m using the latest versions of all the software, but I’m running bbpress on a local machine using MAMP. not sure if that is part of the problem.

    Posted on 29-Oct-09 at 5:42 pm | Permalink
  9. Deryk

    one more thing, the second user, no matter what their user level (even up to admin) cannot see the file the other user uploaded, nor can they even submit their own attachment. strange.

    Posted on 29-Oct-09 at 6:02 pm | Permalink
  10. Andrea

    Am I supposed to install this in /mu-plugins, or in /plugins? I can’t seem to make it work either way… Am I supposed to see something in addition to the regular posting box that allows me to upload attachments? Thanks…I really want to get this working so I can launch my site. :-)

    Posted on 01-Nov-09 at 8:28 am | Permalink
  11. @Deryk – Thanks for the feedback. I’m out of town for a few weeks but when I get back I will try to replicate your issues.

    @Andrea – /plugins should be fine, as long as you’re sure to activate it on the main blog of your site (ie the one where BuddyPress is activated). It could be that you’re not seeing the Attachments section on the new post screens because you didn’t enter the hooks (at all, or in the correct places). Make sure that you’re putting them in the correct theme files, ie the ones at /wp-content/themes/, NOT at /wp-content/plugins/buddypress/bp-themes.

    Posted on 04-Nov-09 at 3:44 pm | Permalink
  12. Andrea

    @Boone — Thanks so much! I reloaded, recoded, and reactivated, and it’s working fine now. Is there a way to increase the file upload size? Also, are movie (.mov, .wmv, etc.) uploads possible?

    Posted on 04-Nov-09 at 4:42 pm | Permalink
  13. Hi Andrea. Yes, you can allow more file types and increase the permitted file size. Open up the plugin php file and check out the first part of the file. You’ll see a bunch of variables being defined, among which are permitted file types and file size. You’ll notice as well that permissions are separate for different kinds of users (administrators, authors, etc), permissions that I think are inherited (such that administrators can do everything that authors can do, PLUS whatever extra things you can do).

    This configuration method – manually editing the plugin file – is the way that _ck_ originally set things up in the bbPress plugin. It’s nice because it doesn’t add the unnecessary overhead of an administration screen on the Dashboard, but it’s difficult for non-programmers to edit (especially given that there’s no documentation of how it works). One of my plans for improving the plugin is to move these settings – or the important ones, at least – to a regular Dashboard admin panel. Stay tuned!

    Posted on 04-Nov-09 at 6:26 pm | Permalink
  14. Glittereyes

    Hi,

    In this plugin how do I modify the comment “allowed uploads: bmp (500 KB), doc (500 KB), gif (500 KB), gz (500 KB), jpeg (500 KB),
    jpg (500 KB), pdf (500 KB), png (500 KB), txt (500 KB), xls (500 KB), zip (500 KB)” at the bottom of the page?

    Posted on 09-Nov-09 at 10:34 am | Permalink
  15. Hi Glittereyes,

    It depends what you mean.

    If you want to change the permitted file types, you can do that in the configuration section of the plugin file (near the top). There you can specify the file types and sizes that can be uploaded. The text at the bottom of each page should be adjusted automatically.

    If you just want to change the text, find the function bb_attachments_upload_form. You can change the words “allowed uploads” manually. The rest of the text (the list of file types) is generated automatically. You could delete some or all of it by modifying the echo line within that function.

    Posted on 09-Nov-09 at 3:43 pm | Permalink
  16. @Deryk – Not sure if you’re following this thread, but after a bit of playing around it seems as if the view/upload permissions at the very beginning of the plugin’s settings need to be set to “read” in order to work right. Haven’t quite figured out why that’s the case, but I assume it’s because BP user roles are handled differently (or at least named differently) from bbPress roles. I don’t think it will cause a problem if you allow readers to have upload permissions, because the attachment box is located inside the new post form, which is protected from non-group-members by BuddyPress.

    I’ll be making these changes to the default settings in the trunk. Thanks for your feedback.

    Posted on 12-Nov-09 at 5:53 pm | Permalink
  17. @slaFFik – I added the upload box to the edit screens. Good call.

    I tried to replicate your deletion problem, but I couldn’t. I had no problem deleting file attachments, as the URLs were all correct. Are you talking about clicking the little ‘x’ next to an attachment?

    Posted on 12-Nov-09 at 6:05 pm | Permalink
  18. Wesley Shaw

    Just plugged it in and it seems to be working beautifully. Latest trunk (I think) of Buddypress and WPMU. Thanks much for porting this over.
    Is there a trick to getting the file-type icons to render correctly? I know you know they’re broken, I’m just wondering if I can help. Not really a coder, though, so probably not.
    Again: thanks.

    Posted on 12-Nov-09 at 9:09 pm | Permalink
  19. Wesley Shaw

    Here’s my oddity: so long as I stay in Safari (mac 4.0.3), everything seems to work well. However, Firefox (3.5.5) only downloads erratically. The odd thing to me: the links seem to be generated correctly on both browsers (ie, the URLs are identical) but Firefox just can’t manage to grab the file. I get this message: “Firefox can’t find the file at http://. . . . . ” If I cut and paste that same address to the Safari toolbar, it downloads fine. For the record, I’m logged in to my install as admin in both accounts, and have also tried logging in as a different user.

    Posted on 13-Nov-09 at 11:49 am | Permalink
  20. Wesley Shaw

    OK, one more interesting note: when I upload a .doc file, it shows up correctly in my server, but when I download it it’s somehow changed to a .dot file. It still opens fine in MS Word, but I’m wondering if that has something to do with why Firefox doesn’t like it.

    Posted on 13-Nov-09 at 1:00 pm | Permalink
  21. Mike Greening

    Hi Boone,

    Thanks for working on this, it’s a great idea. I’ve installed the plugin and tried three different file types: .jpg, .doc, and .xls. All three file types uploaded, but I was only able to download the jpgs. The jpg files open within the same browser window.

    Trying to download the .doc or the .xls from within the post gives me the following error:

    Firefox can’t find the file at http://safe-state.com/groups/test-group/forum/topic/try-this-one/?bb_attachments=6&bbat=6.

    Can you identify something I might not have done correctly?

    Posted on 27-Nov-09 at 9:55 pm | Permalink
  22. Hi Mike,

    Thanks for the comments.

    What’s your server setup? Are you running Apache? Are you finding the same problem in different browsers?

    I’ve had some similar problems with the plugin over the past week or so, as I try using it in different environments. I think it has to do with the plugin itself – there are issues with the way that it sends headers to the client browsers as they try to download files. My development team and I are getting closer to figuring out what the heck is going on, and once we do I’ll release a v0.2 of the plugin that addresses the issue.

    Posted on 28-Nov-09 at 12:22 pm | Permalink
  23. Wesley, I think that you’re having the same problems as me and Mike. I’ll keep you informed as I figure out more on my end.

    Posted on 28-Nov-09 at 12:23 pm | Permalink
  24. Mike Greening

    I’m not able to download the .xls or .doc files in IE8 either. I’m getting:

    “Unable to download …(the site string)

    Unable to open this internet site. The requested site is either unavailable or cannot be found. Please try again later.”

    My site is hosted with shared hosting at hostgator and should be running the latest of everything.

    Thanks again, looking forward to the new release. Let me know if there is anything else I can help out with.

    Posted on 28-Nov-09 at 3:12 pm | Permalink
  25. Wesley Shaw

    Boone– thanks for the update. If you’d like detailed information on what I’m running on my servers, let me know and I’ll get right back to you. And I’m happy to test it on a beta site I already have up and running.

    Good luck and thanks for your work on this: once it’s working, it will hugely increase the utility of Buddypress for collaboration/coordination.

    Posted on 11-Dec-09 at 10:20 am | Permalink
  26. paul

    What if you cannot make a directory above the httpdocs?
    “make a directory /bb-attachments/ ABOVE your webroot ie./home/username/bb-attachments/”

    I cannot seem to get the uploads to work. I put the bb_attachments folder in the root of the site and gave it a 777.

    Thoughts?

    Posted on 28-Dec-09 at 12:22 pm | Permalink
  27. I can’t get this to work ata ll. Hosting with Network Solutions, so can’t create a directory outside the web root. Changed the plugin so the image path was correct, but when posting an attachment just see the page reload with a broken image link (apparently for a failed icon) along with the words:

    [failed] filename.jpg

    the path to the broken image icon is utter gibberish by the way and is in the form of:

    http://shoottheislands.comdata/user/n/nn/nn/nn/…../htdocs/….

    No slash after the ‘.com’ and I have no idea what the rest is meant to point at.

    Viewing the forum after this initial upload shows just my post text – no attachements area, no broken icon etc.

    Any clues?

    Posted on 29-Dec-09 at 11:34 pm | Permalink
  28. benjaimieson – There are two problems going on. The first is that the image path seems to be wrong. Look at line 85 of the plugin file forum-attachments-for-buddypress.php. The concatenation there is _ck_’s work, and it’s intended for bbPress, so it’s unsurprising that it doesn’t work for you. I’ll figure out a way to make it BP-friendly, but in the meantime you could just hardcode the path to the forum-attachments-for-buddypress/icons directory. I think it has to be an absolute server path (ie /wwwdocs/wp-content/plugins/forum… ) but I could be wrong.

    The other problem is that files aren’t uploading. That’s probably a path issue, too. Where are you putting the bb-attachments folder, if not above the web root? Try hardcoding the path on line 79 of the plugin. And make sure that you’ve set the permissions on that directly to be world-writable and world-readable (777 will definitely do it)

    Posted on 31-Dec-09 at 7:41 am | Permalink
  29. paul

    I changed the path on line 79 and gave it a 777 but I still get the “[failed]” next to the name of the file I tried to upload.

    Posted on 31-Dec-09 at 7:50 am | Permalink
  30. Paul – when you navigate to the folder via FTP do you see any uploaded files?

    Posted on 31-Dec-09 at 7:56 am | Permalink
  31. paul

    No there is nothing there

    Posted on 31-Dec-09 at 8:02 am | Permalink
  32. Thanks Boone – with a bit of fiddling, I have it half working!

    Now I need to hack it to display JPG uploads inline…. maybe I’ll do that next year…. oh… hang on – that’s tomorrow.

    Posted on 31-Dec-09 at 10:02 am | Permalink
  33. benjamieson – If you figure out how to get images to display inline, please let me know. I have had a doozy of a time making it work (has to do with HTTP headers, I think). Glad you got it working to the extent that you have, though!

    paul – Hm, I’m sort of at a loss. Are you sure you’ve got the right path? It should be an absolute server path, NOT relative to the web root.

    Posted on 01-Jan-10 at 4:41 am | Permalink
  34. paul

    Not sure how to figure the absolute server path out

    Posted on 02-Jan-10 at 5:30 am | Permalink
  35. paul – Put the following (temporary!) line directly after the <body> tag in your theme’s header.php file:
    < ?php echo ABSPATH; ?>
    Then load a WP/BP page in your browser. The absolute path of the WP install will show at the top of your screen. (Then make sure to remove that line from header.php as soon as you’ve taken note of the path.)

    If you’ve put the directory bb-attachments in the WP root (ie the same directory that contains wp-content/, wp-includes/, wp-config.php, etc), then the absolute path on line 79 of the attachments plugin file should be ABSPATH . ‘bb-attachments’, or you can hardcode it.

    Posted on 02-Jan-10 at 5:57 am | Permalink
  36. Not sure why WP put a space between < and ? in the code of my previous comment, but make sure that you take that space out.

    Posted on 02-Jan-10 at 6:31 am | Permalink
  37. paul

    Got it working, thanks for the help!

    In the future it would be cool if it displayed a thumbnail of the image.

    Posted on 02-Jan-10 at 6:54 am | Permalink
  38. Great – glad it’s working!

    You’re right – it would be great to get inline images to show up, either full-size or as thumbnails. It’s on my list of improvements. Thanks for the feedback!

    Posted on 02-Jan-10 at 9:19 am | Permalink
  39. Hello Boone. I am trying to get this plugin to work but no dice. I’ve followed all the instructions and even hard coded the ABSPATH, but nothing uploads, or is there anything in my error logs. Do you have any suggestions? Thanks.

    Posted on 05-Jan-10 at 10:02 pm | Permalink
  40. Hi Joshua. Can you say a little more about what’s happening and what your setup is? Versions of BP/WP? You see the upload interface on the BP forums but nothing uploads? Do you get an error message?

    Posted on 05-Jan-10 at 10:49 pm | Permalink
  41. I don’t get any error messages. I am using BP 1.1.3 and WP 2.8.6. No error messages show up when I try to upload. So, what I did was over write the files with new one to start over. But I guess I did not realize that the upload fields would still be there until I deactivated the plugin. I thought that’s what replacing the tags were for.

    Posted on 05-Jan-10 at 10:55 pm | Permalink
  42. Oh, I should also mention that nothing appears in the bb-attachments directory.

    Posted on 05-Jan-10 at 10:56 pm | Permalink
  43. AlanK

    Hello Boone, I have a question about your notes on this page:

    http://dev.commons.gc.cuny.edu/2009/07/20/making-sitewide-tags-work/

    If I posted a question there would you respond or should I post somewhere else on your blog?

    Alan

    Posted on 06-Jan-10 at 1:14 pm | Permalink
  44. Hi Alan – leave a comment either there or on the corresponding comment on this blog (http://teleogistic.net/2009/07/making-sitewide-tags-work/) and I’ll do my best to help!

    Posted on 06-Jan-10 at 2:12 pm | Permalink
  45. Joshua – I’m not sure what you mean by “replacing the tags”. If you’re talking about the hooks that you added to your template files, then the explanation is that a few extra hooks are needed in templates in order to allow certain pieces of information to appear on your forum pages (to show the forum attachments underneath individual posts, for example). Other items in the plugin are attached to hooks that are already in the default BP themes. I think that the upload fields that appear underneath the entry box are among this latter group.

    As for why uploads aren’t working: there are a lot of places where things could be going wrong. Are you sure that the path to bb-attachments that you hardcoded into the plugin is correct? If you’re on shared hosting, it can sometimes be a little hard to tell what your server path is. Also make sure that bb-attachments is world-writable, 777.

    You might also have a look at the database, if you have access to it (through PHPMyAdmin or something like that). Look for the table bb_attachments in your WP database. 1) Does such a table exist? 2) If so, does the table have any entries in it?

    Posted on 06-Jan-10 at 2:33 pm | Permalink
  46. @Boone, thanks for the reply and clarification. Yes, I am sure that the path is correct, it is a dedicated server, yes the database table is present and no it has no entries. Is there supposed to be a submit button for the attachment before clicking submit?

    Posted on 06-Jan-10 at 5:57 pm | Permalink
  47. Joshua – No, there is no submit button for the attachments, just the post reply button. A couple more things to check:

    1. Are you certain that the form on the submit page has the following enctype?

    2. For testing purposes, you might want to go to the function bb_attachments_process_post (starts around line 350 in the plugin file) and start inserting die statements just to see where the process is getting hung up. Try vardumping the content of various variables at certain places to see where they start coming up empty.
    Posted on 09-Jan-10 at 9:03 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

Additional comments powered by BackType