BuddyDev

Search

[Resolved] Buddyblog activity button

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47554

    Hello,

    Please how can I create a new activity meta button called (Edit or Promote Post) clicking on this button will redirect the logged in user to the post edit page similar to this code below

    See image example https://imgbb.com/q5PMP9W

    I used the code below in single post page but I want the (Edit or Promote Post) activity meta button to link to this same page.

     <?php if ( is_user_logged_in() && is_singular('post') ) : ?>
    <div id="call-to-action" class="edit-action-btn">
    <?php if ( function_exists( 'bblpro_get_post_edit_link' ) ) { echo bblpro_get_post_edit_link( get_the_ID(), array( 'label' => esc_html( 'Edit or Promote This Post ₦' ) ) ); } ?>
    </div> 
    <?php endif; ?>  

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #47557

    Hi Tosin,
    We will check if BuddyPress allows us to add extra markup without applying their kses(otherwise, we will have to use action to add the buttons).

    Ravi or I will update you in next 2 days.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47586

    Kind reminder sir

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2936
    Ravi on #47588

    Hello Tosin,

    Try the following code:

    
    add_action( 'bp_activity_entry_content', function () {
    	global $activities_template;
    
    	if ( ! function_exists( 'bblpro_get_post_edit_link' ) || empty( $activities_template->activity ) || empty( $activities_template->activity->secondary_item_id ) ) {
    		return;
    	}
    
    	$post_id = $activities_template->activity->secondary_item_id;
    	$form_id = bblpro_post_get_form_id( $post_id );
    
    	if ( $form_id ) {
    		echo bblpro_get_post_edit_link( $post_id, array( 'label' => esc_html( 'Edit or Promote This Post' ) ) );
    	}
    } );
    
    

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47592

    Hello Ravi,

    Thanks for the code but I need 2 adjustments

    1. I also want the button to show in the sitewide activity directory

    2. The button is being displayed in the (activity-inner) section instead of (activity-meta) section. I want the link to be displayed in the activity-meta area as an activity-meta button

    Thanks

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47593

    I got the second one figured out by changing bp_activity_entry_meta

    Updated code below

     /* Add buddyblog edit button to activity feed */
    add_action( 'bp_activity_entry_meta', function () {
    	global $activities_template;
    
    	if ( ! function_exists( 'bblpro_get_post_edit_link' ) || empty( $activities_template->activity ) || empty( $activities_template->activity->secondary_item_id ) ) {
    		return;
    	}
    
    	$post_id = $activities_template->activity->secondary_item_id;
    	$form_id = bblpro_post_get_form_id( $post_id );
    
    	if ( $form_id ) {
    		echo bblpro_get_post_edit_link( $post_id, array( 'label' => esc_html( 'Edit / Promote Post' ) ) );
    	}
    } ); 

    Now I just need to display the button in the sitewide activity directory

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47594

    Hi Ravi

    Please kindly ignore as buddyblog was deactivated from the sitewide activity page

    This is now resolved

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47595

    Would it also be possible to add the delete button to activity feed

  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #47599

    Hi Tosin,
    I will recommend against this one. You are going to have a very bad experience as clicking on delete will make users move from current location in stream to profile or some other page.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47626

    I’ll take to your advice thanks sir

    just one more support needed

    How can I also add another activity meta button in (new_classified) activities linking to this page (manage-listings), this button would only be displayed in the activity type (new_classified) and not (new_blog_post)

    Thanks

The topic ‘ [Resolved] Buddyblog activity button’ is closed to new replies.

This topic is: resolved