Automatically post products added as activity update on buddypress

Hi!

1)I'd like to have the products my users add to their stores and auction stores automatically posted at their buddypress' activity page. To give an example, I want products from here: https://www.wheelofcommerce.com/johanschneider/store/products/ and here: https://www.wheelofcommerce.com/auctions/ to be automatically added at their respective buddypress profile, like every other buddypress activity update, here: https://www.wheelofcommerce.com/members/johanschneider/

2)I'd like to have soial buttons to share and like on page like the ones below:
https://www.wheelofcommerce.com/johanschneider/store/products/fabulous-table/
https://www.wheelofcommerce.com/auctions/?ult_auc_id=427
These button can be placed right beneath the product's pic.

If needed, my wp and FTP credentials were sent with Aicee's name at the subject line of the email, 2 weeks ago.

Thanks. :slight_smile:

  • Vinod Dalvi

    Hi Gabriel,

    I hope you are well today and thank you for your question.

    1)I'd like to have the products my users add to their stores and auction stores automatically posted at their buddypress' activity page.

    You can do so by adding the following code in the bp-custom.php file

    add_post_type_support( 'product', 'buddypress-activity' );

    The above code is for the product post type. You have to do the same for Auction post type.

    Find more information about it on the following page.

    https://codex.buddypress.org/plugindev/post-types-activities/

    2)I'd like to have soial buttons to share and like on page like the ones below:

    You can try achieving this using any of the following plugins.

    https://premium.wpmudev.org/project/floating-social/
    https://wordpress.org/plugins/simplified-social-share/
    https://wordpress.org/plugins/social-share-button/
    https://wordpress.org/plugins/social-sharing-toolkit/

    Best Regards,
    Vinod Dalvi

  • Wheel of Commerce

    1)It worked for the regular stores, but not for the autions:
    add_post_type_support( 'auction', 'buddypress-activity' );
    Also, I tried using Network Wide Text Change to change "wrote a new item" to "added a new product", that's displayed at the bp activity stream, but it didn't work.

    2)Thanks for the suggestions, I'll check on that. Would they place the button at a nice spot, or would I have to use CSS or something to correct that? Just wondering.

    Thanks again, man. :slight_smile:

  • Vinod Dalvi

    Hi Gabriel,

    Thank you for your quick reply.

    1)It worked for the regular stores, but not for the autions:

    The Auction custom post type name is ultimate-auction so please try using the following code.

    add_post_type_support( 'ultimate-auction', 'buddypress-activity' );

    Also, I tried using Network Wide Text Change to change "wrote a new item" to "added a new product", that's displayed at the bp activity stream, but it didn't work.

    I could change the sentence "wrote a new" on your site using Network Wide Text Change module. To change item word to product try using the attached small plugin containing the following code.

    function wpmu_gettext_with_context( $translated_text, $untranslated_text, $domain ) {
        if ( 'buddypress' == $domain ) {
            if (strpos($untranslated_text,'item') !== false) {
    		   $translated_text = str_replace("item","product", $untranslated_text);
            }
        }
    
        return $translated_text;
    }
    add_filter( 'gettext', 'wpmu_gettext_with_context', 10, 3 );

    2)Thanks for the suggestions, I'll check on that. Would they place the button at a nice spot, or would I have to use CSS or something to correct that? Just wondering.

    You can try placing it in the right spot using the shortcodes provided by them orelse we have to place it using CSS code.

    Regards,
    Vinod Dalvi

  • Wheel of Commerce

    Thanks for answering so fast. :slight_smile:

    That code for the auction part worked, but contrary to what happened with the regular store, the product's image isn't being displayed, also, the text reads: " [...] added a new item, on the site Wheel of Commerce", using site instead of store, and the wp-admin name instead of the user's name.

    I've tried inserting that plugin both as a regular and as mu plugin, but it didn't work.

    Thanks again, man. You're being extremely helpful with this. :slight_smile:

  • Vinod Dalvi

    Hi Gabriel,

    That code for the auction part worked, but contrary to what happened with the regular store, the product's image isn't being displayed, also, the text reads: " [...] added a new item, on the site Wheel of Commerce", using site instead of store, and the wp-admin name instead of the user's name.

    I am not sure i understood this correctly so could you please explain it a bit more in detail and share the page URLs and screenshots where it's happening so that i can troubleshoot it?

    I've tried inserting that plugin both as a regular and as mu plugin, but it didn't work.

    Please try using the attached modified plugin version as a regular plugin.

    Regards,
    Vinod Dalvi

  • Wheel of Commerce

    Hi, man!

    You can see what I'm talking about in this activity feed: https://www.wheelofcommerce.com/members/johanschneider/ . You can also see a screen shot of the issue here: http://i.imgur.com/YzqIt32.png, the post in the activity feed has no image, while the product at the auction section has, and the text reads "[...] added a new item, on the site Wheel of Commerce", while it should read "[...] added a new product, on the store Johan Scheider's Store", the name of the store being a link to it, just like the post below it, that was generated from the regular stores, not the auction sections. Since now I'm trying to link to the auction section, I still have to figure out what's the page that displays all auctions from an user (I'm searching, but didn't find it so far). I'v contacted the plugin's dev on that, but if you can figure it out, that'd be great too.

    The plugin didn't work. I's supposed to change the words in activity feed updates that are already there, right? Or will the changes only be applied to new products I add, in a way that to test the plugin, I have to add a new product every time?

    Thanks. :slight_smile:

  • Vinod Dalvi

    Hi Gabriel,

    the post in the activity feed has no image, while the product at the auction section has

    Please tell me how i can reproduce the issue on your site so that i can resolve it.

    and the text reads "[...] added a new item, on the site Wheel of Commerce", while it should read "[...] added a new product, on the store Johan Scheider's Store",

    I could make it work on your site by updating the provided plugin code.

    Could you please check it and let me know how it works for you?

    The plugin didn't work. I's supposed to change the words in activity feed updates that are already there, right? Or will the changes only be applied to new products I add, in a way that to test the plugin, I have to add a new product every time?

    The plugin should work for all new and old product updates.

    Regards,
    Vinod Dalvi

  • Wheel of Commerce

    Hi, man!

    To reproduce the issue, use the inforation I've sent with Aicee's name 2 weeks ago, login using the johanschneider account, then add a new auction here:
    https://www.wheelofcommerce.com/dashboard/?dashboard=add-auction
    Select the start date as current day and time, or else it won't display in the Manage auctions tab. Now, go to the activity feed of johanschneider and check for the update: https://www.wheelofcommerce.com/members/johanschneider/

    About the plugin: okay, please update the code. I see you didn't attach any new version of it this time, so I'm guessing you'll post this on your next answer.

    About WPMU Floating Social: I've installed the plugin and set it up on both the network and wp-admin, it's completely broken. It's not being displayed on most pages and when it does get shown, it's totally out of place, like in the middle of the page, as you can see here (scroll down and you'll see it): https://www.wheelofcommerce.com/johanschneider/store/products/fabulous-table/

    Considering the nature of these issues, I really think it's better if you use the credentials I've provided in that email with Aicee's name to log into my site and dig into this. If for any reason you can't do that, of course, I can keep following the instructions you provide, but I'd rather do it the way I've mentioned, as it consumes far less time. Besides, I've been in constant contact with tech support, mostly you guys and some of my plugins' devs, trying to solve precisely 25 issues at the same time right now, so making things easier really helps me a lot. :slight_smile:

    Thanks again, man. I appreciate you helping me with this. :slight_smile:

  • Wheel of Commerce

    Update with what was discussed with Patrick during a chat session:

    Here's all the content inside my bp-custom.php:

    <?php
    // hacks and mods will go here
    
    add_post_type_support( 'product', 'buddypress-activity' );
    add_post_type_support( 'ultimate-auction', 'buddypress-activity' );
    
    add_action( 'bp_init', 'customize_product_tracking_args' );
    add_action( 'bp_init', 'customize_auction_tracking_args' );
    
    function customize_product_tracking_args() {
            // Check if the Activity component is active before using it.
            if ( ! bp_is_active( 'activity' ) ) {
                    return;
            }
    
            bp_activity_set_post_type_tracking_args( 'product', array(
                'component_id'             => buddypress()->blogs->id,
                'action_id'                => 'new_blog_product',
                'bp_activity_admin_filter' => __( 'Published a new product', 'custom-domain' ),
                'bp_activity_front_filter' => __( 'Products', 'custom-domain' ),
                'contexts'                 => array( 'activity', 'member' ),
                'activity_comment'         => true,
                'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">product</a>', 'custom-textdomain' ),
                'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">product</a>, on the site %3$s', 'custom-textdomain' ),
                'position'                 => 100,
            ) );
    }
    
    function customize_auction_tracking_args() {
            // Check if the Activity component is active before using it.
            if ( ! bp_is_active( 'activity' ) ) {
                    return;
            }
    
            bp_activity_set_post_type_tracking_args( 'ultimate-auction', array(
                'component_id'             => buddypress()->blogs->id,
                'action_id'                => 'new_blog_auction',
                'bp_activity_admin_filter' => __( 'Published a new auction', 'custom-domain' ),
                'bp_activity_front_filter' => __( 'Auctions', 'custom-domain' ),
                'contexts'                 => array( 'activity', 'member' ),
                'activity_comment'         => true,
                'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">auction</a>', 'custom-textdomain' ),
                'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">auction</a>, on the site %3$s', 'custom-textdomain' ),
                'position'                 => 100,
            ) );
    }
    
    ?>

    Here you can see what's left to be fixed:
    https://www.wheelofcommerce.com/members/johanschneider/
    1)Lack of image from auctions.
    2)"site" must be replaced by "store".
    3)The update from auctions is displaying "Wheel of Commerce" instead of that user's own auction section.
    4)The update from regular stores has "wrote" instead of "added".
    5)The product link from auctions redirects to an empty page, instead of the page with that auction, which for that case is https://www.wheelofcommerce.com/auctions/?ult_auc_id=443

    Thanks.

  • Wheel of Commerce

    Update with what was discussed with Vinod during a chat session:

    This is the new code that's at my bp-custom.php at the moment:

    <?php
    // hacks and mods will go here
    
    add_post_type_support( 'product', 'buddypress-activity' );
    add_post_type_support( 'ultimate-auction', 'buddypress-activity' );
    
    add_action( 'bp_init', 'customize_product_tracking_args' );
    
    function customize_product_tracking_args() {
            // Check if the Activity component is active before using it.
            if ( ! bp_is_active( 'activity' ) ) {
                    return;
            }
    
            bp_activity_set_post_type_tracking_args( 'product', array(
                'component_id'             => buddypress()->blogs->id,
                'action_id'                => 'new_blog_product',
                'bp_activity_admin_filter' => __( 'Published a new product', 'buddypress' ),
                'bp_activity_front_filter' => __( 'Products', 'buddypress' ),
                'contexts'                 => array( 'activity', 'member' ),
                'activity_comment'         => true,
                'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">product</a>', 'buddypress' ),
                'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">product</a>, on the store %3$s', 'buddypress' ),
                'position'                 => 100,
            ) );
    }
    
    function customize_auction_tracking_args() {
            // Check if the Activity component is active before using it.
            if ( ! bp_is_active( 'activity' ) ) {
                    return;
            }
    
            bp_activity_set_post_type_tracking_args( 'ultimate-auction', array(
                'component_id'             => buddypress()->blogs->id,
                'action_id'                => 'new_blog_auction',
                'bp_activity_admin_filter' => __( 'Published a new auction', 'buddypress' ),
                'bp_activity_front_filter' => __( 'Auctions', 'buddypress' ),
                'contexts'                 => array( 'activity', 'member' ),
                'activity_comment'         => true,
                'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">auction</a>', 'buddypress' ),
                'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">auction</a>, on the store %3$s', 'buddypress' ),
                'position'                 => 110,
            ) );
    }
    ?>

    Here you can see what's left to be fixed:
    https://www.wheelofcommerce.com/members/johanschneider/
    1)Lack of image from auctions: the plugin of Ultimate Auction Pro told me the following about that:

    PRO plugin does not set featured/thumbnail image. PRO acts as child theme to your parent theme and overrides content and since it does not set featured image so buddypress is also not able to get it.

    Any way to somehow have an image at the bp activity feed?

    2)"item" must be replaced by "auction" at the updates that come from the auction area.

    3)"site" must be replaced by "store" at the updates that come from the auction area.

    4)The updates from auctions are displaying "Wheel of Commerce" instead of that user's own auction section.

    5)The updates from regular stores have "posted" instead of "added".

    6)The product link from auctions redirects to an empty page, instead of the page with that auction. Example: that update that says "beach 5" redirects to this empty page: https://www.wheelofcommerce.com/blog/ultimate-auction/beach-5/ while the correct page for that auction is this one: https://www.wheelofcommerce.com/auctions/?ult_auc_id=460

    Thanks. :slight_smile:

  • Ash

    Hello @Gabriel

    I hope you are well today.

    1. If there is no images set as featured image, it is not possible to get any image for corresponding auction.

    2. 3. 4. Those are already done in the latest code you posted in the last reply. Are you sure you have that code in your site? Please confirm.

    5. Try this:

    <?php
    // hacks and mods will go here
    
    add_post_type_support( 'product', 'buddypress-activity' );
    add_post_type_support( 'ultimate-auction', 'buddypress-activity' );
    
    add_action( 'bp_init', 'customize_product_tracking_args' );
    
    function customize_product_tracking_args() {
            // Check if the Activity component is active before using it.
            if ( ! bp_is_active( 'activity' ) ) {
                    return;
            }
    
            bp_activity_set_post_type_tracking_args( 'product', array(
                'component_id'             => buddypress()->blogs->id,
                'action_id'                => 'new_blog_product',
                'bp_activity_admin_filter' => __( 'Published a new product', 'buddypress' ),
                'bp_activity_front_filter' => __( 'Products', 'buddypress' ),
                'contexts'                 => array( 'activity', 'member' ),
                'activity_comment'         => true,
                'bp_activity_new_post'     => __( '%1$s added a new <a href="%2$s">product</a>', 'buddypress' ),
                'bp_activity_new_post_ms'  => __( '%1$s added a new <a href="%2$s">product</a>, on the store %3$s', 'buddypress' ),
                'position'                 => 100,
            ) );
    }
    
    function customize_auction_tracking_args() {
            // Check if the Activity component is active before using it.
            if ( ! bp_is_active( 'activity' ) ) {
                    return;
            }
    
            bp_activity_set_post_type_tracking_args( 'ultimate-auction', array(
                'component_id'             => buddypress()->blogs->id,
                'action_id'                => 'new_blog_auction',
                'bp_activity_admin_filter' => __( 'Published a new auction', 'buddypress' ),
                'bp_activity_front_filter' => __( 'Auctions', 'buddypress' ),
                'contexts'                 => array( 'activity', 'member' ),
                'activity_comment'         => true,
                'bp_activity_new_post'     => __( '%1$s added a new <a href="%2$s">auction</a>', 'buddypress' ),
                'bp_activity_new_post_ms'  => __( '%1$s added a new <a href="%2$s">auction</a>, on the store %3$s', 'buddypress' ),
                'position'                 => 110,
            ) );
    }
    ?>

    6. Nope, this is right. You are referring to this page: https://www.wheelofcommerce.com/wp-admin/post.php?post=402&action=edit (this is a page)

    But when buddypress picks the CPT, it will pick the original Custom Post Type URL. I have set a custom redirect for those auction CPTs to redirect to the auction page using this code in your mu-plugins:

    add_action( 'template_redirect', 'auc_red_to_page' );
    function auc_red_to_page() {
        if( is_singular( 'ultimate-auction' ) ){
            global $post;
            wp_redirect( 'https://www.wheelofcommerce.com/auctions/?ult_auc_id=' . $post->ID );
            die();
        }
    }

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Wheel of Commerce

    Hi, man! Thanks for taking the time to look into this thoroughly, I appreciate that. :slight_smile:

    1)I'll prob pay the plugin's dev to fix that.

    2, 3 and 4)All are still occurring.

    5)Solved.

    6)Solved.

    7)[NEW ISSUE]:
    Now the products from the regular stores are also not getting their images posted in the updates. I think this started after the installation of that plugin Vinod developed to fix the issue with WPMU PM and setting up a featured image. Here's that thread:
    https://premium.wpmudev.org/forums/topic/my-users-are-unable-to-set-featured-images#post-910514

    Thanks. :slight_smile:

  • Wheel of Commerce

    Update:
    Regarding issue number 7, I've deactivated Vinod's plugin and WPMU PM, and the images from the regular stores still aren't being displayed at the bp activity feed. The issue persists even after deleting Vinod's plugin. Since, as far as I know, the plugin was the only thing affecting this whole part, I really have no idea what's going on here.

    On the wording there: Jude recommended me the following plugin, and told me it would allow me to select where specificcally I'd like a term to be replaced. I've installed it, but I simply can't find a way to achieve that, here's the settings page for it in wp: https://www.wheelofcommerce.com/wp-admin/tools.php?page=search-regex.php
    The plugin:
    https://wordpress.org/plugins/search-regex/

    Thanks.

  • Michael Bissett

    Hey @Gabriel,

    Regarding issue number 7, I've deactivated Vinod's plugin and WPMU PM, and the images from the regular stores still aren't being displayed at the bp activity feed. The issue persists even after deleting Vinod's plugin. Since, as far as I know, the plugin was the only thing affecting this whole part, I really have no idea what's going on here.

    After digging into this further on your site, I'm seeing that products/auctions that have images in the content are having their images imported, but that the posts which don't have an image in the content (and that only have a featured image) don't have their images attached.

    You're certain that there was a time when featured images from products were being pulled into the activity feed? Right now, I'm only seeing that it does this for posts (out of the box).

    On the wording there: Jude recommended me the following plugin, and told me it would allow me to select where specificcally I'd like a term to be replaced. I've installed it, but I simply can't find a way to achieve that, here's the settings page for it in wp: https://www.wheelofcommerce.com/wp-admin/tools.php?page=search-regex.php
    The plugin:
    https://wordpress.org/plugins/search-regex/

    I'll need to ask my colleague @Jude about this, as it seems like he had a particular idea when it came to this.

    Kind Regards,
    Michael

  • Wheel of Commerce

    Thanks for answering. :slight_smile:

    You're right, from the regular stores, what's being posted at the activity stream is the regular image, not the featured one. The question now is: considering that the auction plugin doesn't use featured images, how come those are not being displayed at the feed?

    On the wording: okay, I'll wait for @Jude here. But since that probably won't work, as the plugin wasn't even able to detect the word "item" when searching for it, is there any other solution?

    Thanks again.

  • Wheel of Commerce

    Okay, I'll test that. :slight_smile:

    The dev of the auction plugin asked me this:

    How does BP activity feed pick up auction images? You are trying to do that but do you have any knowledge why/how BP is supposed to do that? I only know that I've coded so that auction title, url and images are shared socially and if some other needs a thumbnail to display on it like BP then I've to custom code it on your site.

    Any ideas here?

    Thanks.

  • Michael Bissett

    Hey @Gabriel,

    The dev of the auction plugin asked me this:

    How does BP activity feed pick up auction images? You are trying to do that but do you have any knowledge why/how BP is supposed to do that? I only know that I've coded so that auction title, url and images are shared socially and if some other needs a thumbnail to display on it like BP then I've to custom code it on your site.

    Right now, the only way I'm seeing that BuddyPress picks up images for an auction is if an image is manually inserted into the description (the "This is another test auction" auction on your site being an example of this).

    Otherwise, as he mentioned, custom coding would be needed to use an image inserted in a different way (e.g. an image inserted into one of the "Product Image" fields available when setting up an auction).

    Hope this helps! :slight_smile:

    Kind Regards,
    Michael

    P.S. In the process of him custom developing this, he may find this to be useful:

    https://buddypress.org/support/topic/add-post-featured-image-in-activity-stream/#post-175246

  • Wheel of Commerce

    Haha, I still want to implement some functions before recording the promotional video, like making statistics avaible for users, so vendors can see from which country they're getting more accesses, a vendor rating system, this sort of thing. I'll prob have to hire a dev for those though, at least to adjust an already installed plugin for those functions, if that's the case.

    Thanks for all the help. :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.