Skip to:
Content
Pages
Categories
Search
Top
Bottom

Limit the size of user updates

  • @latenitebooks

    Participant

    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)
  • @latenitebooks

    Participant

    Anything? Anyone?

    @pisanojm

    Participant

    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.

    https://codex.buddypress.org/home/

    Best regards.

    @thelandman

    Participant

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

    @hnla

    Participant

    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.

    @mercime

    Participant

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

    @hnla

    Participant

    @mercime Thanks for the heads up

    @latenitebooks

    Participant

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

    @mercime

    Participant

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

    @pcwriter

    Participant

    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

    @pcwriter

    Participant

    @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! :-)

    @thelandman

    Participant

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

    @pcwriter

    Participant

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

    @pcwriter

    Participant

    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?

    @thelandman

    Participant

    @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 :)

    @resabi

    Participant
Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Limit the size of user updates’ is closed to new replies.
Skip to toolbar