BuddyDev

Search

[Resolved] Buddypress moderation button shortcode

Tagged: 

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38913

    Good day sir,

    How is the progress

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #38914

    Hi Tosin,
    Thank you.

    I am sorry, we haven’t been able to make any progress as I caught covid mid April. I have recovered since then but I am not sure when we can push an update for this.

    For the time being, Can you please use the code snippet?

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38918

    sure I can use code snippet

    Thanks

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #38926

    Hello Tosin,

    Try the following code. It will add button with post title.

    
    
    /**
     * Add report button with title
     *
     * @param string $title Post Title.
     *
     * @return string
     */
    function buddydev_add_report_button( $title ) {
    
    	if ( ! function_exists( 'bpmts_user_can_report' ) ) {
    		return $title;
    	}
    
    	$post_type = 'post';
    
    	if ( get_post_type() === $post_type && bpmts_user_can_report() ) {
    		$title .= bpmts_get_report_button(
    			array(
    				'item_id'    => get_the_ID(),
    				'item_type'  => $post_type,
    				'context'    => $post_type,
    				'context_id' => get_the_ID(),
    			)
    		);
    	}
    
    	return $title;
    }
    add_filter( 'the_title', 'buddydev_add_report_button' );
    
    

    Please do let me know if you need any assistance with this code.

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38929

    The code messed up this page https://www.nigerpress.com/archive/ the code should not show or display blog post archive pages for posts and other custom post types. The button should only display in the title of single posts and single adverts.

    The button is also displaying in menu
    see link for example https://www.nigerpress.com/article/business-palm-oil-saga/

    The button is also not showing in the custom post type advert see https://www.nigerpress.com/advert/high-quality-traditional-clothing-wares/

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #38933

    Hi Tosin,
    Please do not used the above code. Ravi misunderstood the question and provided code for a different purpose. I am working on a release today for moderation tools. Will be providing the code after that.

    Thank you
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38942

    ok noted ive removed the code

    thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #38944

    Thank you Tosin.
    1. Please upgrade to the latest version.
    2. Please add the following code

    
    
    // disable moderation tools reporting button after the post content.
    add_filter( 'bpmts_is_reporting_button_enabled', function ( $enabled, $location, $args ) {
    
    	if ( 'after_post_content' === $location ) {
    		$enabled = false;
    	}
    
    	return $enabled;
    }, 10, 3 );
    

    That will disable the automatic button in the post content.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38945

    Thanks

    But now how will I output the button in a custom location inside my theme files using maybe do shortcode to output the button.

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #38955

    Hi Tosin,
    Thank you.

    Please use the shortcode form this reply.

    https://buddydev.com/support/forums/topic/buddypress-moderation-button-shortcode/#post-36569

    Regards
    Brajesh

The topic ‘ [Resolved] Buddypress moderation button shortcode’ is closed to new replies.

This topic is: resolved