Forum Replies Created
-
I have the buttons displaying fine in entry.php..thanks for that info however.
To answer your questions milestones and momentum buttons really only need to act like the “spam” button, which when clicked, writes a “1” to the is_spam row in bp_activity table. So, I’ve created is_momentum and is_milestone rows in my db, and just need the logic on how I can get those buttons we have created to act like the “spam” button EXCEPT writing to a new row in table. ANd how to name the “php bp_activity_unfavorite_link” part of the button. That’s all.Hope that’s more clear now.
Chris
Here’s what I have done so far:
/activity/entry.php
<!-- BEGIN Custom Commenting Buttons --> <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( 'Is Milestone?', 'buddypress' ); ?>"><?php _e( 'Is Milestone?', 'buddypress' ); ?></a> <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( ' Is Momentum Point?', 'buddypress' ); ?>"><?php _e( 'Is Momentum Point?', 'buddypress' ); ?></a> <!-- END Custom Commenting Buttons -->
(Just grabbed the button code for “unfavorite/favorite”, so I could have placeholders for my 2 custom buttons)
/bp-custom.php
(code taken from bp-activity-functions.php, well the is_spam piece).// Mark each as milestone foreach ( (array) $activities['activities'] as $activity ) { // Create an activity object $activity_obj = new BP_Activity_Activity; foreach ( $activity as $k => $v ) { $activity_obj->$k = $v; } // Mark as milestone bp_activity_mark_as_milestone( $activity_obj ); // Tidy up unset( $activity_obj ); } // Mark all of this user's activities as milestone $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_milestone = 1 WHERE user_id = %d", $user_id ) ); // Mark each as momentum point foreach ( (array) $activities['activities'] as $activity ) { // Create an activity object $activity_obj = new BP_Activity_Activity; foreach ( $activity as $k => $v ) { $activity_obj->$k = $v; } // Mark as momentum point bp_activity_mark_as_momentum( $activity_obj ); // Tidy up unset( $activity_obj ); } // Mark all of this user's activities as momentum point $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_momentum_point = 1 WHERE user_id = %d", $user_id ) );
Hope this helps make sense of things somewhat.
Chris
Here’s what I have done so far:
/activity/entry.php
<!-- BEGIN Custom Commenting Buttons --> <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( 'Is Milestone?', 'buddypress' ); ?>"><?php _e( 'Is Milestone?', 'buddypress' ); ?></a> <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( ' Is Momentum Point?', 'buddypress' ); ?>"><?php _e( 'Is Momentum Point?', 'buddypress' ); ?></a> <!-- END Custom Commenting Buttons -->
(Just grabbed the button code for “unfavorite/favorite”, so I could have placeholders for my 2 custom buttons)
/bp-custom.php
(code taken from bp-activity-functions.php, well the is_spam piece).// Mark each as milestone foreach ( (array) $activities['activities'] as $activity ) { // Create an activity object $activity_obj = new BP_Activity_Activity; foreach ( $activity as $k => $v ) { $activity_obj->$k = $v; } // Mark as milestone bp_activity_mark_as_milestone( $activity_obj ); // Tidy up unset( $activity_obj ); } // Mark all of this user's activities as milestone $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_milestone = 1 WHERE user_id = %d", $user_id ) ); // Mark each as momentum point foreach ( (array) $activities['activities'] as $activity ) { // Create an activity object $activity_obj = new BP_Activity_Activity; foreach ( $activity as $k => $v ) { $activity_obj->$k = $v; } // Mark as momentum point bp_activity_mark_as_momentum( $activity_obj ); // Tidy up unset( $activity_obj ); } // Mark all of this user's activities as momentum point $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_momentum_point = 1 WHERE user_id = %d", $user_id ) );
Hope this helps make sense of things somewhat.
Chris
I found it 😉 so, now what do I do with it?
chris
@henrywright…javascript *is enabled yes.
What I’m wanting to do, is duplicate those buttons with a new function close to how is_spam functions where it writes a “1” to a row in a db table. I can add the buttons in /activity/entry.php etc..but just need to know how exactly/where to copy the is_spam functionality and where to add to fire off a “replica”. if that makes sense.@danbp..
Thanks. I don’t have buddypress-functions.php in my legacy/buddypress folder? Any thoughts?
bp-activity-actions.php I do have however.-c-
So, is that how the spam or favorite/un favorite buttons work?
And how about the functions?
Chris
Henry:
I’m only looking to basically take the favorites button and modify the function. Is there a guide to this somewhere?
Chris