Skip to:

Add @mentions in plugin

  • btees


    Hey Guys,

    I hope this is in the right section.

    I’m using awpcp for wordpress to create a classified ads website (for people to swap stuff they no longer use, not sell it!)

    Awpcp has a comment form plugin but it’s extremely basic, at the moment it’s just adding plain text to the bottom of the page when someone comments.

    I’ve been able to edit it so the username links to the users buddypress profile, but I’d really like @mentions to link to profiles and send notifications to users tagged, appear in activity feeds, etc.

    Right now it just shows up as plain text.

    Can anyone steer me in the right direction as to how I might achieve this?

    Cheers guys 🙂

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

  • Henry Wright


    I guess the awpcp plugin will need to add @-mention support to their comment form. Try asking this same question on their support forum.



    Thanks for the reply @henrywright. As much as I like awpcp for somethings, development seems to be very slow. I was hoping to hack the plugin but can’t seem to find any documentation on implementing @mentions in plugins. I’m likely not searching the right terms

    @btees It probably hasn’t been documented. 😀

    First, see if a mentions.min.js or mentions.js is loaded on the screen you want at-mentions support added to. If it is, try adding the CSS class bp-suggestions to the textarea that your users will be typing in, and test again. If that doesn’t work, open up the mentions.js script and start debugging.

    Otherwise, if the script isn’t being loaded, you’ll need to know some PHP. I’d suggest you start looking at bp_activity_mentions_script() and bp_activity_maybe_load_mentions_scripts(). You probably need to filter bp_activity_maybe_load_mentions_scripts() to return true when the visitor is on the screen whereever you want to add mentions support. Once you can get the script loaded, go back a paragraph and follow those JS debugging steps.

    You’ll have to implement the activity stream and notification integration seperately, but I think just adding at-mentions is pretty straightforward and a good start. Let me know how you get on!



    Hi @djpaul,

    Thanks a lot for that, now I’m getting somewhere!

    Neither mentions.min.js or mentions.js were loading on awpcp pages so I put the following in my footer:

    <?php if ( is_page( 4792 ) ): ?>
        <script type='text/javascript' src=''></script>
    <?php endif; ?>

    I also added the bp-suggests class to the textarea.

    I’m now getting suggestions on the input box which is a good start!

    But when the comments are posted they are still just appearing in plain text.

    Is there a css class that should be added to the comment container? Or would this be part of implementing the activity stream and notification integration?

    Try running the custom content through the bp_activity_at_name_filter filter.



    Hey @djpaul I followed the steps here up until your last comment where you lost me! I have mentions working in comments and what now, but when I press enter to select the mention it writes it in plain text. Where would I be using bp_activity_at_name_filter to make sure when I select it, it creates the appropriate link? Or is it done when the comment is posted? Thanks!

    Looks like the mentions are parsed and URL wrapped once the comments are posted 😀 happy days!

    Somewhere, at some point, Awpcp will print the comments to the web page (so people can read them). You’ll need to find where this happens, and run the text through the bp_activity_at_name_filter filter before the comment template is printed to the page.

    For example, it might look like:

    <?php echo $comments; ?>

    You’d change it to:

    <?php echo apply_filters( 'bp_activity_at_name_filter', $comments ); ?>



    @djpaul Just edited my comment above! Looks like it will do that after the comment is posted!



    Hi @djpaul. Thanks again for your help.

    The comments section in Awpcp is added to single ad page layout via the wordpress backend. It calls the comment section by placing $comments where you want the comment section to be.

    From the looks of it, the entire page that awpcp creates for listings doesn’t.

    This looks like integrating this may be a bit beyond me right now. I’m looking to hire a developer.

    I was looking to post in the bp jobs board here but it’s closed to new comments (it seems to be closed quite recently)

    Does anyone have a suggestion as to where I might post this?

    Thanks again for all your help.

    I accidentally closed that board; it should be open, though I don’t know how many people look at it, to be honest.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar