I am trying to post a comment to the "Site-Wide Activity" page from a custom page. I have been looking around for a solution but nothing works.
How can I post an image and comment using a custom basic script like the one below?
<?php
if (isset($_POST["submitToActivity"])) {
$arrayPost = [$_POST["imgUrlString"],$_POST["comment-user"] ];
add_post_type_support( $arrayPost, 'buddypress-activity' );
echo "$UserName Posted a new comment";
}
?>
<form method="post" name="sendToActivity">
<label>Url Img</label>
<input type="text" id="imgUrlString" name="imgUrlString" />
<label>Comment</label>
<input type="text" id="comment-user" name="comment-user" />
<input type="submit" name="submitToActivity" id="submitToActivity">
</form>
add_post_type_support()
doesn't save anything, it just declares (in this case) the support of storing some data (new post of that post type) in BuddyPress activity feed. More info about BuddyPress support here. You will need to read the doc about this function here as well, as you are adding support incorrectly.
It seems, that you need to take a look at bp_activity_add($args);
, here is the doc.