Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How do I Post to buddypress activity feed on form submit WordPress


I have a form on my website that allows users to write a review about the content on the page.

Here is the form code:

I would like to know how I can achieve this….

1. User submits form
2. Activity stream entry created: "USER has just submitted a review on PAGENAME in CATEGORY 8 minutes ago"


* Avatar displayed before activity feed item
* USER: links to user profile
* PAGENAME: the name of the page the form was submitted on with link
* CATEGORY: links to the category the page is a part of

I would love it to be a filterable item in the activity feed called Reviews (similar to Everything, updates, posts, etc)

For the life of me I can't figure it out, I won't share any code as I've tried a lot and it's all failed.

Can anyone help?

Answers (1)


Hariprasad Vijayan answers:


Not clear about your requirement. Can you show url and which section you want these changes.

tp comments:

Happy to...

My site is members only so use
* username: testuser
* password: testuser!,

1) User submits form on this page:
2) I would like an activity post to appear on the buddypress activity feed here:

Hariprasad Vijayan comments:

Please don't share credentials here.

Hariprasad Vijayan comments:

I can't able to login. Is that credentials are correct?

tp comments:

It's just a test user account to view the form - no admin access is granted.

tp comments:

Checked and they work:

username "testuser"
password "testuser!,"

Hariprasad Vijayan comments:

Okay.. Where the review is storing?

Hariprasad Vijayan comments:

Can you share credential in PM

tp comments:

The reviews are stored in a separate database table. Would that need accessing? I would have thought there would be a hook on the form that is accessible on submit?

Hariprasad Vijayan comments:

No. No need of accessing it. Am just clarifying.

Hariprasad Vijayan comments:


You can use the following code for adding an activity while submitting review and it will automatically display in your activity feed.
Code is

$current_user = wp_get_current_user();
$user_login = $current_user->user_login;
$username = $current_user->user_firstname ;
global $bp;
$userlink= 'http://localhost/wordpress/member/'.$user_login;
$action = '@'.$username.' has just submitted a review on PAGENAME in CATEGORY';
global $bp;
bp_activity_add (
'action' => $action,
'primary_link' => $userlink,
'component' => 'activity',
'type' => 'activity_update',
'user_id' => $bp->loggedin_user->id,
'item_id' => $bp->displayed_user->id

You need to change the following details with yours
1. $userlink
This is working in my localhost perfectly. Please ask if you need any more help.

tp comments:

That looks promising, where should I add that code? It doesn't appear to reference anything aside form user details, is that correct?

tp comments:

Ah ok, in the form!

Appears to be working. Let me test properly

Hariprasad Vijayan comments:

Any doubt? Please let me know?

tp comments:

OK, I have added the code within <?php brackets ?> to the page where the form is, and it does create activity stream items, however it produces 3 posts (attached image).

Do you get the same?