Forum Replies Created
-
Hey @Marcella, 10 bucks is awesome! I can drink to BuddyPress and the possibilities it represents
You can find the donation link on my blog http://alextheafrican.wordpress.com/
Thanks!
Beer! Most definitely!
You’re right about the template/theme version of the code. It looks a lot friendlier than the core version
Pleasure to have helped!
So I finally cracked what’s ailing this forum’s comment posting code If you include a properly referenced superglobal variable in your comment content, then the system just replies with “It looks like you’ve already said that! ”
Anyway, in the code that I’ve posted above, you’ll need to replace all occurrences of _POST with the proper superglobal variable reference.
Second part:
1. Create the file theme/activity/reply.php and put in the following code:
global $bp;
// Check the nonce
check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
if ( !is_user_logged_in() ) {
bp_core_add_message( __( 'You must be logged in to post a comment', 'buddypress' ), 'error' );
}
else {
if ( empty( _POST ) ) {
bp_core_add_message( __( 'You left out the comment.', 'buddypress' ), 'error' );
}
else {
if ( empty( _POST ) || !is_numeric( _POST ) ) {
bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' );
}
else {
$comment_id = bp_activity_new_comment( array(
'activity_id' => _POST,
'content' => _POST,
'parent_id' => _POST
) );
if ( !$comment_id ) {
bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' );
}
else {
bp_core_add_message( __( 'Comment posted successfully', 'buddypress' ) );
}
}
}
}
2. In functions.php, add the function:
function bp_activity_action_add_activity_comment( ) {
global $bp;
// Not viewing activity or action is not delete
if ( !bp_is_activity_component() || !bp_is_current_action( 'reply' ) )
return false;
locate_template( array( 'activity/reply.php' ), true );
bp_core_redirect( wp_get_referer() );
}
add_action( 'bp_actions', 'bp_activity_action_add_activity_comment' );
hahaa! It could as well be.Let me see if splitting up the message sort it out:
First part:
It’s my understanding that the problem is arising from the form submitting to /activity/reply/ which isn’t recognized by WordPress and therefore causing the 404. Here’s some code to address that. The idea is to have WordPress accept /reply/ as a valid destination by getting BuddyPress to pick it up as an action.Every time I try to post the comment I get the message “It looks like you’ve already said that! ” and yet nothing is showing. So where is it!
@Marcella, I’ve posted code, but it’s not showing up so I guess there’s something I’m missing or it’s being held for moderation.
Hey @Marcella, are you still stuck on this? If so, what’s the structure of your code/pages so far? I may be able to help…