WordPress.org

Ready to get started?Download WordPress

Forums

BuddyPress Activity Plus
[resolved] Database distinction for different update types (16 posts)

  1. jchew
    Member
    Posted 2 years ago #

    Hello WPMU Dev,

    Firstly, thank you for this great plugin. It is a great addition to the BuddyPress activity stream. There is, however, one feature that would be very useful to have.

    It would be great if there was something on the database end to give developers the ability to distinguish between a photo / link / video update type.

    On looking in the database, the only differences between the update types I could find was the shortcode used to output the media content. Please let me know if I am missing something!

    - Jeff

    http://wordpress.org/extend/plugins/buddypress-activity-plus/

  2. klipari
    Member
    Posted 2 years ago #

    Hi Jeff!

    While I'm not familiar with the Database rules and writing for this plugin I can certainly ask the developer for some more information on this!

    I'll be back!

    :)

  3. klipari
    Member
    Posted 2 years ago #

    One thing though! It would be very helpful to know how you intend to use this information!

    Thanks!

  4. jchew
    Member
    Posted 2 years ago #

    Hello klipari,

    The idea would be to be able to create new filters for the "Activity" feed that could be used show only photo updates, video updates, or link updates. Similar to how Facebook makes a distinction between a photo post, video post, link post, etc.

    If there were some piece of meta data in the database that reflected what type of "activity update" was made, that would be more than half the battle.

    Thanks so much for your quick response!

  5. juanmaguerrero
    Member
    Posted 2 years ago #

    Indeed that is much needed! That would be great. I have tweaked this plugin a lot, improving it amazingly (look for example in my dev test site, the way the images look ;) http://www.soysurfista.com/miembros/admin/activity/173 ) ando a lot of other stuff. But yet I could not figure out were I could send a different activity type in the "posting the update" process... if you can give us a clue it would be great... thanks for everything!

  6. juanmaguerrero
    Member
    Posted 2 years ago #

    Ok, I'm making some advance, I changed the function that saves the activity ( /lib/class_bpfb_binder.php ):

    // All done creating tags. Now, save the code
    $gid = (int)@$_POST['group_id'];
    if ($bpfb_code) {
      global $bp;
      $content = @$_POST['content'] . "\n" . $bpfb_code;
      $content = apply_filters('bp_activity_post_update_content', $content);
      $user_id = $bp->loggedin_user->id;
      $aid = $gid ?
        groups_post_update(array('content' => $content, 'group_id' => $gid))
        :
        //bp_activity_post_update(array('content' => $content))
        bp_activity_add(
          array(
            'content' => $content,
            'component' => 'custom_name', //this is the custom activity record
            'type' => 'custom_name', //this is the custom activity record
            'user_id' => $user_id
          )
        )
    			;
  7. juanmaguerrero
    Member
    Posted 2 years ago #

    Ok, I've completely done it :D This is the code:

    /**
     * THIS IS WHERE WE ACTUALLY SAVE THE ACTIVITY UPDATE.
     */
    function ajax_update_activity_contents () {
      $bpfb_code = $activity = '';
      $aid = 0;
      $codec = new BpfbCodec;
      if (@$_POST['data']['bpfb_video_url']) {
        $bpfb_code = $codec->create_video_tag($_POST['data']['bpfb_video_url']);
        $type = 'bpfb_share_link';
      }
      if (@$_POST['data']['bpfb_link_url']) {
        $bpfb_code = $codec->create_link_tag(
          $_POST['data']['bpfb_link_url'],
          $_POST['data']['bpfb_link_title'],
          $_POST['data']['bpfb_link_body'],
          $_POST['data']['bpfb_link_image']
        );
        $type = 'bpfb_share_link';
      }
      if (@$_POST['data']['bpfb_photos']) {
        $images = $this->move_images($_POST['data']['bpfb_photos']);
        $bpfb_code = $codec->create_images_tag($images);
        $type = 'bpfb_share_wall_photos';
      }
    
      $bpfb_code = apply_filters('bpfb_code_before_save', $bpfb_code);
    
      // All done creating tags. Now, save the code
      $gid = (int)@$_POST['group_id'];
      if ($bpfb_code) {
        global $bp;
        $content = @$_POST['content'] . "\n" . $bpfb_code;
        $content = apply_filters('bp_activity_post_update_content', $content);
        $user_id = $bp->loggedin_user->id;
        $userlink = bp_core_get_userlink( $user_id );
    
        $author = bp_core_get_userlink( $author_id );
        $activity_url = bp_activity_get_permalink( $item_id );
    
        $aid = $gid ?
          groups_post_update(array('content' => $content, 'group_id' => $gid))
          :
          // Acá intercepto el envío y lo customizo para poder discriminar tipos diferentes de actividad =D @Juanma
          //bp_activity_post_update(array('content' => $content))
          bp_activity_add(
            array(
              'action' => apply_filters( 'activity_update', sprintf( __( '%s compartió un enlace', 'buddypress' ), $userlink ), $user_id ),
              'content' => $content,
              'component' => 'activity',
              'type' => $type,
              'user_id' => $user_id
            )
          )
        ;

    And below also added the activity filters options ;) (still a bit hardcoded but):

    /**
     * bpfb_activity_links_filter()
     *
     * Adds 'Enlaces' and 'Wall Photos' to activity stream filters.
     *
     */
    function bpfb_activity_links_filter() {
    	echo '<option value="bpfb_share_link">Enlaces</option>';
    	echo '<option value="bpfb_share_wall_photos">Fotos del muro</option>';
    }
    add_action( 'bp_activity_filter_options', 'bpfb_activity_links_filter' );
    add_action( 'bp_member_activity_filter_options', 'bpfb_activity_links_filter' );
    add_action( 'bp_group_activity_filter_options', 'bpfb_activity_links_filter' );

    Hope it helps you also, @jchew ;)

  8. klipari
    Member
    Posted 2 years ago #

    Oh wow that's awesome!

  9. juanmaguerrero
    Member
    Posted 2 years ago #

    Thanks! I must say I corrected lots of "bugs" for saying, maybe if the developers of this plugin would like me to send "my" copy of bp activity plus" for taking a look at it and maybe find some useful corrections just let me know or drop me an email at juanmaguerrero.com [at] gmail [dot] com ;) cheers!

  10. klipari
    Member
    Posted 2 years ago #

    I've let him know about your fix, I'm sure he will stop in. :)

    Great Job !

  11. KrYsT
    Member
    Posted 2 years ago #

    Could we have a running copy of your plugin uploaded somewhere? I couldn't manage to get mine running with the code you posted. Thanks in advance

  12. jrgiblette
    Member
    Posted 1 year ago #

    I can't seem to get this code to work @jaunmaguerrero. Would you mind sharing how to add this?

  13. juanmaguerrero
    Member
    Posted 1 year ago #

    Hi, @jrgiblette, well you have to basically replace the parts that I pasted here starting from (around):
    "THIS IS WHERE WE ACTUALLY SAVE THE ACTIVITY UPDATE"...

    It is an example of course, I made that when users post videos or links or photos, it has a different html class attribute instead of the default, and that "new different types" of activity also get registered in the database, so the system can understand that, for example: "activity item id: 123 --> has "x" content --> and it's type is "bp_share_video".

    With this, below, I tweak the way the activities are shown, for example I can make the system to output "USERNAME has shared a video!!!" instead of the standard "USERNAME posted an update" text string.

    Well, you have to of course modify my example to suit your needs, and this will work for all activity items created from the moment you applied it an so on, not backwards (although you of course can always tweak the database ;) ).

    Let me know in which instance you are stuck, in the implementation, in tweaking my code, when you test what is the error that you see... so I can help further.

    Cheers,

    -JM

  14. ellbristow
    WPMU DEV Support Staff
    Posted 1 year ago #

    Hi there,

    We're just tidying up the support forums for our plugins and wondered if you mind marking this thread as resolved since you have provided your own fix to the issue.

    The details have been forwarded to our developer and I'm sure he will look at merging your code with our main plugin.

    Thanks!

  15. juanmaguerrero
    Member
    Posted 1 year ago #

    Hi, @ellbristow I'm not really the thread author and think that's why I don't find a link to "close thread" or something like that. It seems that the original thread creator hasn't looked at this since long ago... :(

  16. tom.eagles
    Member
    Posted 1 year ago #

    @ellbristow

    Thanks for letting us know anyway

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic