Skip to:
Content
Pages
Categories
Search
Top
Bottom

Limit the size of user updates

  • Avatar of Brian Kittrell
    Brian Kittrell
    Participant

    @latenitebooks

    I am wondering if there is any way to limit the size of a user’s update. For instance, on this page (http://www.latenitebooks.com/members/kittrellbj/), users can post updates about themselves similar to Facebook status messages.

    I want the ability to limit the size of these things, similar to the way Facebook or Twitter limits the total size of a single update. If it is an administrator, it can be any size. If it is a moderator, limit to 1000 characters. If it is a regular user, limit the size to around 150 characters or less.

    That’s the only kind of spam I get hit with these days. I had someone come on the site and post a 26-page advertisement 6 times. It clogged my RSS feed, and that took about 30 minutes to get straightened out.

    If anyone knows of a solution, let me know. I’ll even program it myself and release a plug-in for it if someone can at least give me a link to that part of the API.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Avatar of Brian Kittrell
    Brian Kittrell
    Participant

    @latenitebooks

    Anything? Anyone?

    Avatar of Pisanojm
    Pisanojm
    Participant

    @pisanojm

    Hi Brian,

    It’s a good question and I’m sure someone will get back to you. Typical etiquette here states that you need to give 24-48 hours before “bumping” a post here because the site is not large enough to get an “instant answer” in such a short period and nearly everyone here is a volunteer… Have you checked the codex… -if you are a programmer you may be able to glean something out of the code, information, and loops posted there.

    http://codex.buddypress.org/home/

    Best regards.

    Avatar of thelandman
    thelandman
    Participant

    @thelandman

    @latenitebooks, This should point you in the right direction…

    Example: http://www.ajaxray.com/Examples/charLimit.html
    Tutorial: http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/

    Basically, you would apply the tutorial to the found in the post-form.php and the entry.php.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    It’s probably not a great idea to do something like this via client side scripting especially given the circs for wanting to do this. A filter function ought to be created to handle it.

    It’s worthy of looking at with a view to creating a plugin or functions.php function, shouldn’t be too difficult to do and I might have a look later time permitting or hopefully one of the more skilled members with the BP API might suggest an approach.

    Avatar of @mercime
    @mercime
    Keymaster

    @mercime

    @hnla plugin being created by someone at this time, hopefully out within next few days.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    @mercime Thanks for the heads up

    Avatar of Brian Kittrell
    Brian Kittrell
    Participant

    @latenitebooks

    @mercime Any word on the plugin you were talking about?

    Avatar of @mercime
    @mercime
    Keymaster

    @mercime

    @latenitebooks plugin delayed because of another plugin.
    There are non-plugin solutions which would involve manually adding javascript on relevant pages and code within respective forms. Also, If I’m not mistaken, the plugin I mentioned would be good for child themes of bp-default theme but would require some addition of template tags for non-bp-default themes.

    Avatar of pcwriter
    pcwriter
    Participant

    @pcwriter

    See the 2nd example on this page:
    http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/

    …and view the source of this page:
    http://www.ajaxray.com/Examples/charLimit2.html

    Just a few lines of javascript added to your page/template and an onkeyup event added to each textarea.

    This works just dandy :-)
    To see it in action, log into my site with username:buzzer and pass:123abc456
    Check the homepage or any member /activity/ page.
    500 char limit is applied to the textarea in post-form.php

    Avatar of pcwriter
    pcwriter
    Participant

    @pcwriter

    @latenitebooks

    To get you started, here’s a replacement file for activity/post-form.php with a 500 character textarea limit.
    http://pastebin.com/eXuSa4iK

    Adjust to taste on line 52. With an if/else conditional, you could set it so different roles have different limits.
    Simply create a new post-form.php file in your child theme, copy/paste the contents of the pastebin file and upload to the “activity” folder of your child theme.

    Hope it helps! :-)

    Avatar of thelandman
    thelandman
    Participant

    @thelandman

    @pcwriter, you may also want to implement the same to the entry.php so you can limit the characters in the reply text area. Exactly what I’ve done on my site.

    Avatar of pcwriter
    pcwriter
    Participant

    @pcwriter

    @thelandman

    Thanks for the reminder, but here’s something odd:

    I can only get the char limit to work on the first activity item. The script is between the `

    ` tags, and this is my textarea.

    `<textarea id="ac-input-” class=”ac-input” name=”ac_input_” onkeyup=”limitChars(this, 500, ‘charlimitinfo’)”>`

    Did you do any mods to the script or textarea on your entry.php? And if so, care to share?

    Avatar of pcwriter
    pcwriter
    Participant

    @pcwriter

    Correction: the char limit DOES work throughout the page.
    It’s the `charlimitinfo` that displays the char countdown ONLY on the first activity item.

    Any ideas?

    Avatar of thelandman
    thelandman
    Participant

    @thelandman

    @pcwriter, the charlimitinfo will only display on the first activity item because you’ve specified for it to only show up on that specific div with that id. Here’s the solution:

    `<textarea id="ac-input-” class=”ac-input” name=”ac_input_” onkeyup=”limitChars(this.form.ac_input_, 500, ‘charlimitinfo-’)” />`

    In each activity item the textarea has a unique name and id applied to it. The javascript function will now be called to each individual activity item.

    Hope that helps :)

    Avatar of Eddie
    Eddie
    Participant

    @resabi

Viewing 15 replies - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.