Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add buddypress favorite button on a blog post


  • cding
    Participant

    @cding

    I want to add the buddypress favorite button on a blog post. There are several topics about this, but none works. Can anyone help me?

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

  • cding
    Participant

    @cding

    en, maybe some works, but I can’t understand.


    leog371
    Participant

    @leog371

    Hiya CDing, check this out. Its pretty self explanitory. Add BuddyPress Favorite Button On posts


    cding
    Participant

    @cding

    It looks great! thx!


    cding
    Participant

    @cding

    @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?


    leog371
    Participant

    @leog371

    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>

    cding
    Participant

    @cding

    @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.


    leog371
    Participant

    @leog371

    in that case simply make it visible only to the comment author when he or she is logged in.


    cding
    Participant

    @cding

    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.


    leog371
    Participant

    @leog371

    Oh no, you should be making a child theme. Anytime you update that theme, your works could be lost forever.


    cding
    Participant

    @cding

    Yes, I have made a child theme of twentyseventeen. I just don’t know where to put the codes you gave.

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