Skip to:
Content
Pages
Categories
Search
Top
Bottom

Modify hook for posting new activity comment


  • digitalminion
    Participant

    @digitalminion

    Hello,

    Just wanted to put out an idea for modifying the hook used when creating new content for activity comments.

    At the moment in the function bp_activity_new_comment found in bp-activity-functions.php,
    an apply_filter is called on the content of the comment using the hook bp_activity_comment_content.

    This same hook is used to apply filters when retrieving the comment content in bp_get_activity_comment_content in bp-activity-template.php

    I ran into trouble with this, as I wanted to modify the contents of the comment on creation, but didn’t want to run the same function against the comments when they are loaded to be displayed. In particular I wanted to apply wp_kses to the content to strip anchor tags supplied by the user, but as it stands since the same hook is used when loading the content (after bp_get_activity_content hook filters are applied which includes the bp_activity_truncate_entry function), the system added [Read More] link is rendered as plain text.

    I’m sure there are several ways around this involving removing filters etc, but it strikes me as odd that that for example activity and group updates have the hooks bp_activity_new_update_content and groups_activity_new_update_content respectively for modifying user input content but it isn’t the same for comments.

    My proposal would be to modify the function bp_activity_new_comment found in bp-activity-functions.php to call a hook bp_activity_new_comment_content on the content instead of bp_activity_comment_content. That way there is a unique hook for comment content creation.

    Just wanted to put it out there to the community to see if someone more familiar with the code base sees this as an inconsistency or if there is a reason for doing it this way.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modify hook for posting new activity comment’ is closed to new replies.
Skip to toolbar