en, maybe some works, but I can’t understand.
Hiya CDing, check this out. Its pretty self explanitory. Add BuddyPress Favorite Button On posts
@leog371 The codes work very well! And I also want add buddypress delete comment button after each comment on a blog, so the comment user could delete their own comment. I tried hours but failed to modify the add favorite codes. I konw little about php, would you like to give a hand?
Hi Cding, you shouldn’t be doing that in the Add Favorites Code, that is a separate function and would be a button or Input that would be placed next to the add favorites button if you want it there. The code would look something like this.
**Needs to be a function**
if ( isset( $_POST['comment_delete_nonce'] ) ) {
if( wp_verify_nonce( $_POST['comment_remove_nonce'], 'comment-remove-nonce' ) ) {
set_query_var( 'commentid1', $_POST['commentid'] );
wp_delete_comment( get_query_var( 'commentid1'), true );
wp_safe_redirect( wp_get_referer() ); exit;
}
}
And on the template file
<form method="POST" action="" class="delete-comment-form">
<input type="hidden" name="comment_remove_nonce" value="<?php echo wp_create_nonce('comment-remove-nonce'); ?>" />
<input type="hidden" name="commentid" value="<?php comment_ID() ?>" />
<input type="submit" value="Delete" title="Delete" id="submit-btn" class="btn" />
</form>
@leog371 It seems you use the wp delete comment function. I want the comment author can delete their own comment and this is why I want to use buddypress delete activity function. Does your function allow the comment author to delete their own function?
And it is difficult for me find where to put the second codes.
I try to put it after
<?php
wp_list_comments( array(
'avatar_size' => 100,
'style' => 'ol',
'short_ping' => true,
'reply_text' => twentyseventeen_get_svg( array( 'icon' => 'mail-reply' ) ) . __( 'Reply', 'twentyseventeen' ),
) );
?>
but it is not the right place. I want show the button after each comment.
in that case simply make it visible only to the comment author when he or she is logged in.
Oh, that would be very good!
I’m sorry that I know nearly nothing about codes.
By **need to be a function**, do you mean I have to put the code into function.php and add “my_function{…}”?
I really do not know where to put the second code. My theme is twentyseventeen.
Oh no, you should be making a child theme. Anytime you update that theme, your works could be lost forever.
Yes, I have made a child theme of twentyseventeen. I just don’t know where to put the codes you gave.