Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter johnsen

    (@johnsen)

    Thanks for the answer. And thank you for a great product.

    I think I have found a solution by inserting the ad image into the activity stream. I would like to share the solution with others here.

    Solution for BuddyBoos/BuddyPress:

    /* Add Title, Image, Content and Price Activty Streame on Ad Submit */
    
    add_action( "init", function() {
        remove_action( 'publish_advert', 'adext_bp_activity_add' );
        add_action( 'publish_advert', 'my_adext_bp_activity_add' );
    }, 20 );
    function my_adext_bp_activity_add( $post_id ) {
        $post = get_post( $post_id );
        $activity = get_post_meta( $post_id, "wpadverts_bp_activity_add", true );
    
        if( $activity > 0 ) {
            // Activity already recorded
            return;
        }
        if ( ! bp_is_active( 'activity' ) ){
            return;
        }
    
        $m = __( '%3$s udgav en ny annonce <a href="%2$s">%1$s - SE MERE...</a>', 'wpadverts-bp' );
    
        $content = "";
    
    /** Insert Ad Titel */
    	$content .= "<h2><strong>". get_the_title( $post_id ) . "</strong></h2><br/>" ;
    
    /** Insert Ad Image */
        $image_id = adverts_get_main_image_id( $post_id );
        if( $image_id ) {
            $content .= sprintf( '<img src="%s" alt="" /> ', adverts_get_main_image( $post_id ) );
        }
    /** Insert Ad Content */
    	$content .= "<br/>". get_the_excerpt( $post_id ) . "<br/>";
    
    /** Insert Ad Price */	
    	$content .= "<b>". adverts_get_the_price( $post_id ) . "</b>";
    	
        $activity_id = bp_activity_add( array(
            "action" => sprintf( $m, $post->post_title, get_the_permalink( $post_id ), bp_core_get_userlink( $post->post_author ) ),
            "content" => $content,
            "component" => "wpadverts-bp",
            "type" => "new_classified",
            "primary_link" => get_permalink( $post_id ),
            "user_id" => $post->post_author,
            "item_id" => $post_id,
        ) );
    
        add_post_meta( $post_id, "wpadverts_bp_activity_add", $activity_id );
    }
    Thread Starter johnsen

    (@johnsen)

    Tanks, worked fine, but if i want the Ads feature image shown on the activity feed, how do i get that to work?

    To clear things, i want to show the ads like this in the activity streame :

    {Title}
    {Feature image}
    {Ad text}
    {Ad price}
    {Read more}

    Hope you get the idea?

    • This reply was modified 5 years, 2 months ago by johnsen.

    Hey, i have the same problem, when switching from English to Danish, the date field is show with alot for dates.

    English :
    Test Meeting
    16. November 2020 at 21:00 (Copenhagen)

    Danish :
    Test Meeting
    16 November 2020#!30Mon, 16 Nov 2020 21:00:00 +0100p0030#30Mon, 16 Nov 2020 21:00:00 +0100p-9Europe/Copenhagen3030Europe/Copenhagenx30 16pm30pm-30Mon, 16 Nov 2020 21:00:00 +0100p9Europe/Copenhagen3030Europe/Copenhagenx302020Mon, 16 Nov 2020 21:00:00 +01000090011pmMonday=1379#!30Mon, 16 Nov 2020 21:00:00 +0100pEurope/Copenhagen11# at #!30Mon, 16 Nov 2020 21:00:00 +0100p0030#/30Mon, 16 Nov 2020 21:00:00 +0100p-9Europe/Copenhagen3030Europe/Copenhagenx30#!30Mon, 16 Nov 2020 21:00:00 +0100pEurope/Copenhagen11#21:00 (Copenhagen)

    I’m using the same plugIn as pawel108, and get the same text as he is, any one found solution for this problem ??

    /niels

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