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
    [code language=’html’][/code]
    Next: After line 61, which reads
    [code language=’html’][/code]
    insert the following line
    [code language=’html’][/code]
    Next: On line 26, replace
    [code language=’html’]

    [/code]
    with
    [code language=’html’]

    [/code]
  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.

61 thoughts on “Help me alpha test BuddyPress Forum Attachments

  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!

  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.

  3. Ray

    Boone,

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

    Automattic really doesn’t like me! :p

  4. Boone Post author

    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!

  5. slaFFik

    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.

  6. slaFFik

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

  7. Boone Gorges

    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!

  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.

  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.

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

  11. Boone Post author

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

  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?

  13. Boone Post author

    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!

  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?

  15. Boone Post author

    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.

  16. Boone Post author

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

  17. Boone Post author

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

  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.

  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.

  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.

  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?

  22. Boone Post author

    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.

  23. Boone Post author

    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.

  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.

  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.

  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?

  27. benjaimieson

    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?

    1. Boone Gorges Post author

      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)

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

  29. benjamieson

    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.

  30. Boone Gorges Post author

    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.

  31. Boone Gorges Post author

    paul – Put the following (temporary!) line directly after the <body> tag in your theme’s header.php file:

    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.

  32. paul

    Got it working, thanks for the help!

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

  33. Boone Gorges Post author

    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!

  34. Joshua Parker

    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.

  35. Boone Gorges Post author

    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?

  36. Joshua Parker

    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.

  37. Boone Gorges Post author

    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?

  38. Joshua Parker

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

  39. Boone Gorges Post author

    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? <form action="" method="post" id="forum-topic-form" class="standard-form" enctype="multipart/form-data">
    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.
  40. Ray

    Hey Boone,

    I’m testing the bbPress attachments plugin on BP 1.2 and it works for the most part.

    I’m trying to make some cosmetic changes (changing a couple of headings), but I keep getting a cached result.

    I checked out the bb_attachments_cache() function, but I’m not sure how to override the cache.

    It’s probably something stupid on my part!

    When you have some spare time, can you help me debug this?

    Thanks!

  41. Boone Gorges Post author

    Hi Ray,

    I will take a detailed look sometime soon, but off the top of my head I seem to remember that bb_attachments_cache is a cached object containing all the attachment data, NOT a cache of the markup itself. Or is that what you mean?

  42. Ray

    I’m looking for some way to disable the cache, or at least, a way to see my changes.

    If I try to change the header, for example, from [h3]Attachments[/h3] to [h4]Attachments – Test text[/h4], I don’t see any of the changes.

    Like I said, I’m probably overlooking something very simple – I’m just not looking in the right area!

  43. Ray

    Everything works fine, except activating the plugin?
    Seriously, the plugin is listed as inactive, yet I can upload and download the attachments in the forums.

    I’m on WPMU 2.9.1.1 and BP 1.1.3 using the buddypress magazine theme from wpmudev.org

    I made the changes to the topic, edit and index.php files before I activated the plugin, would that have mattered? I also tried to activate it site-wide before activating it simply on the main blog.

    I dunno – but it works!

  44. gever tulley

    so… doesn’t work in BP 1.2.1, right?

    based on:
    – there’s no index.php in groups/single/forum/ anymore
    – there’s no ‘template_notices’ hook in topics.php

    anyone ported this yet or know of something with a similar capability that is BP 1.2.1 compatible?

  45. Boone Gorges Post author

    Hi gever. I haven’t even looked at how the code works in BP 1.2+. r-a-y says above that the basic functionality (the uploading parts) still work fine, but the new bp-default theme is sufficiently different that it will probably take a fair amount of work to make all of the UI parts appear correctly.

    r-a-y – Sorry for ignoring your comment for so long. I think that really I just want to ignore this plugin, as it has caused me some nightmares. In any case, you might need to make sure that the cache function is being hooked to a function that actually exists, otherwise the refresh won’t happen. I will look at the code sometime next week and let you know what I find. Ideally I’ll release something fully 1.2 compatible (and by “fully” I mean “as bug-free as my code ever gets)

    Avatar Ray – I have no idea what the problem is, but as long as it’s working, I’ll put that bug fairly low on my todo list 🙂

  46. Emma

    Hi
    I really don’t get this – cannot find any of the code you refer to for altering as in the instructions at the top of this page!
    I am running latest version of single install of wordpress with the new version of buddypress written for this system.
    I have forums enabled in buddypress which uses a bbpress install. The forums etc works ok.
    I want to be able to add attachment with the forum posts but it isn’t working. It throws up errors on the screen, and although the new reply can be accessed the uploaded files are nowhere to be seen!
    I am fairly new to all of this which dosen’t help.
    Please can you help me?
    Cheers
    Emma

  47. Boone Gorges Post author

    Emma – this plugin has not yet been updated for the newest versions of BP. Others have told me that it’s possible to make this version of the plugin work with BP 1.2.1, but it takes a bit of knowledge of how templates work.

    I’ll be having a look at this plugin within the next week or two and will post an update on my blog when I’ve got it working properly.

  48. Emma

    Thanks Boone
    I just don’t have the know how (yet – something to work on!) but it would be a really useful plugin for me if it worked 🙂 Will keep an eye on your blog.
    Emma

  49. Pingback: Плагин: прикрепление данных в темах форумов групп | CosyDale.com: WordPress (MU) и BuddyPress

  50. Pingback: 2009 by the numbers | Teleogistic

Comments are closed.