Forum Replies Created
-
Solved:
function get_fav_or_unfav_button_for_bpp( $reply ) { global $bp, $activities_template; // user is not logged ? Show nothing. if ( ! is_user_logged_in() ) { return ''; } $activity_id = (int) get_post_meta( bbp_get_reply_id( $reply_id ), '_bbp_activity_id', true ); if ( ! $activity_id ) { return ''; } bp_has_activities(); // update $activities_template of user's fav $old_value = false; if ( isset( $activities_template->activity->id ) ) { $old_value = $activities_template->activity->id; $activities_template->activity->id = $activity_id; } else { $activities_template->activity = (object) array( 'id' => $activity_id ); } // building the template $code = ''; $code .= '<div class="activity-like-count">'."\n"; if ( ! bp_get_activity_is_favorite() ) { // if not favorited, add a fav button $code .= ' <a href="'.bp_get_activity_favorite_link( ).'" class="acomment-like fav-comment bp-secondary-action" title="'.__( 'Like', 'buddypress' ).'">'.__( 'Like', 'buddyboss' ).'</a>'."\n"; } else { // if already favorited, a button to unfav $code .= ' <a href="'.bp_get_activity_unfavorite_link( ).'" class="acomment-like unfav-comment bp-secondary-action" title="'.__( 'Unlike', 'buddypress' ).'">'.__( 'Unlike', 'buddyboss' ).'</a>'."\n"; } // closing .activity-meta $code .= '</div>'."\n"; if ( false !== $old_value ) { $activities_template->activity->id = $old_value; } else { $activities_template->activity = null; } return $code; } ?>
Add to loop-single-reply.php for BBPress:
<?php echo get_fav_or_unfav_button_for_post( reply ); ?> or in the bbp_reply_menu, which i’m still trying to figure out:
In reply to: Help with custom bbpress Like/Dislike pluginAh don’t worry about hijacking your own thread, I will make a separate thread since the solutions are clearly different.
In reply to: Help with custom bbpress Like/Dislike pluginThe trick is to relate the activity ID to the Post ID of the forum topic or reply. This code (used for liking (aka favouriting) ) blogpost works. I’m trying to rewrite it for bbpress
In single.php:
<?php echo get_fav_or_unfav_button_for_post( $post ); ?>
In function.php:
// Buddypress favorites function get_fav_or_unfav_button_for_post( $post ) { global $bp, $activities_template; // user is not logged ? Show nothing. if ( ! is_user_logged_in() ) { return ''; } $activity_id = bp_activity_get_activity_id( array( 'user_id' => $post->post_author, 'type' => 'new_blog_post', 'component' => 'blogs', 'item_id' => 1, 'secondary_item_id' => $post->ID ) ); if ( ! $activity_id ) { return ''; } bp_has_activities(); // update $activities_template of user's fav $old_value = false; if ( isset( $activities_template->activity->id ) ) { $old_value = $activities_template->activity->id; $activities_template->activity->id = $activity_id; } else { $activities_template->activity = (object) array( 'id' => $activity_id ); } // building the template $code = ''; $code .= '<div class="activity-meta">'."\n"; if ( ! bp_get_activity_is_favorite() ) { // if not favorited, add a fav button $code .= ' <a href="'.bp_get_activity_favorite_link( ).'" class="button fav bp-secondary-action" title="'.__( 'Like', 'buddypress' ).'">'.__( 'Like', 'buddyboss' ).'</a>'."\n"; } else { // if already favorited, a button to unfav $code .= ' <a href="'.bp_get_activity_unfavorite_link( ).'" class="button unfav bp-secondary-action" title="'.__( 'Unlike', 'buddypress' ).'">'.__( 'Unlike', 'buddyboss' ).'</a>'."\n"; // bonus button to show user's all favs $code .= ' <a href="'.bp_loggedin_user_domain() . 'activity/favorites/" class="button unfav bp-secondary-action">'.__( 'My Likes', 'buddyboss' ).'</a>'."\n"; } // closing .activity-meta $code .= '</div>'."\n"; if ( false !== $old_value ) { $activities_template->activity->id = $old_value; } else { $activities_template->activity = null; } return $code; }
In reply to: Help with custom bbpress Like/Dislike pluginSadly, I can’t revert to a plugin or a own system (all due respect for your solution), my users liked to many activities already.
In reply to: Help with custom bbpress Like/Dislike pluginI’m still trying to integrate the Buddypress favorite (like) system with BBPress, I think this would be the best way to go to integratie the 2 system. Not easy, did any of you guys look at this problem before?
My site: http://www.starry-night.nl
In reply to: using WP_Editor instead of default html editI solved it like this:
// add tinymce for BBPress as default editor add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' ); function bbp_enable_visual_editor( $args = array() ) { $args['tinymce'] = true; $args['media_buttons'] = true; $args['textarea_rows'] = true; $args['dfw'] = false; $args['tinymce'] = array( 'theme_advanced_buttons1' =>'bold,italic,underline,strikethrough,bullist,numlist,code,blockquote,link,unlink,outdent,indent,|,undo,redo,fullscreen', 'theme_advanced_buttons2' => '', // 2nd row, if needed 'theme_advanced_buttons3' => '', // 3rd row, if needed 'theme_advanced_buttons4' => '', ); // 4th row, if needed $args['quicktags'] = array ('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close'); return $args; }