Forum Replies Created
-
I definitely plan to have a demo site in place, I’ve already started building it.
Is there a particular place I should post on this forum to let people know about it and get their feedback?
Nice, I didn’t know that the object could be passed in that way. Very cool indeed.
Also, I checked the
validate
method, and I found thebp_email_validate
filter that I can use to force it to fail the validation as well:From what I understand, I only need to swap the current value with my own WP Error to force it to fail validation and stop sending the BP Email, right? I think this could be a bit smoother for toggling BP Emails on and off via my plugin settings.
Well, not I just need to track down all of those email tokens and we’re in business!
Many thanks for all of your help @shanebp! It’s much appreciated.
My goal with this plugin is to eliminate the need for BP users to have to purchase a theme coded for BuddyPress. And beyond that, it will add a ton of functionality designed to make starting and running a BP community a breeze.
I should have my new BP plugin onto the WP Repo within the next 30 days or so. What do you think is the best way to spread the word to BP users?
Thanks!
How would I go about making the $email object fail the validation step?
I understand that bp_send_email is an action hook, but wouldn’t I need this to be a filter to alter the $email object?
Also, just to give a bit more info on what I’m trying to do.
I want to hook in and send my own email using WP Mail and my own Templating system, and ideally, I’d like to stop BP_Email from sending another duplicate email right after. Whether that’s via the BP PHP Mailer or WP Mail.
Thanks for the super quick response @shanebp!
I did take a look at this filter, but in reviewing the BP_Email class, it would appear that this only disables the BP PHP Mailer templating system, but still sends the email using WP Mail.
I really want to prevent it from sending any BP Emails at all, whether through WP Mail, or the BP_Email system.
I also noticed the “bp_send_email” action hook, which looks like it could be used to collect all of the token data from the email before it is sent:
In theory, I could use this to send my own email using the Email Type and Token data. Is there anywhere in the BP source code that will show me how the associative array for the Token data is formatted? And is there anywhere that I can see a list of the supported Email Types?
Any help with this would be much appreciated!
Thanks Brajesh!
That did the trick. Now both Blog Posts and Comments are appearing on the Activity Stream.
Have a good one.
Awesome, thanks! The template overload and BP theme compat documentation is really insightful.
My goal with this is to create a plugin that loads a BuddyPress theme which can work along with nearly any WordPress theme I switch to. With that said, in your expert opinion, which of the methods you’ve provided will work best from an overall compatibility perspective?
Alright, understood.
Thanks!
Alright, I have an update.
It turns out that BuddyPress Activity Plus was not to blame after all. For some reason, when I use
$retval['object'] = 'status';
it only shows activity updates that I’ve just submitted. Once I refresh the page, the stream is empty again.So I changed the function you provided to try to get around this, and to be conditional to the home page of my eX-Stream site only:
function bpfr_filtering_activity( $retval ) { global $blog_id; // activities to filter on, comma separated if ( $blog_id == 13 && is_front_page() ) { $retval['action'] = 'activity_update'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'bpfr_filtering_activity' );
Thanks a lot @danbp!
The function you provided was EXACTLY what I needed. I appreciate the post you provided with additional info as well. Extremely helpful stuff.
After I added the function I realized that my activity stream was not showing anything. Then, I figured out that the BuddyPress Activity Plus Plugin doesn’t register status updates. So, once I deactivated it, everything was working perfectly.
Thanks again, you are a huge help!
Hi @danbp,
Thanks for helping me out with this. I’m not so worried about the css issue right now, I’m going to get that squared away after I can get this content filter to work. Do you think that I have to add my modified bp-legacy files to my parent theme as well?The only file that I’ve changed in the
bp-legacy/buddypress/activity
folder is activity-loop.php, and I only changed line 3 to the following:<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ).'&object=status' ) ) : ?>
Ok nevermind,
I was able to fix a few syntax errors and get this working. Here’s the code:bp-custom
// Add meta fields upon group creation function bp_group_meta_save ( $group_id ) { $blog = get_blog_details( get_current_blog_id(), true ); $fields = array( 'blog_id' => $blog->blog_id, 'blog_path' => $blog->path, 'blog_name' => $blog->blogname ); foreach ( $fields as $field => $value ) { groups_update_groupmeta( $group_id, $field, $value ); } } add_action( 'groups_created_group', 'bp_group_meta_save' ); function get_groups_by_meta ( $field, $meta_key, $meta_value ) { global $wpdb; if ( is_string( $meta_value) ) $meta_value = "'" . $meta_value . "'"; $sql = $wpdb->prepare( "SELECT $field from {$wpdb->base_prefix}bp_groups_groupmeta WHERE meta_key='$meta_key' AND meta_value=$meta_value", OBJECT ); $res = $wpdb->get_results( $sql ); return $res; } // Build a list of groups with the matching blog_id value function get_groups_by_blogid ( $blog_id = 1 ) { $list = get_groups_by_meta( 'group_id', 'blog_id', $blog_id ); if ( count( $list ) ) { $res = ""; foreach ( $list as $item ) { $res .= $item->group_id . ','; } return substr( $res, 0, -1); } else { return FALSE; } }
groups-loop
<?php $current_blogid = get_current_blog_id(); if ( $current_blogid > 1) { $groups_set = get_groups_by_blogid( $current_blogid ); ( $groups_set !== FALSE ) ? $extra_args = '&include=' . $groups_set : $extra_args = '&include=-1'; } if ( bp_has_groups( bp_ajax_querystring( 'groups' ) . $extra_args ) ) : ?>
Thanks again to @juanlopez4691
Hey guys,
I just wanted to post an update to this.
@juanlopez4691 You’re a genius, the code still works! I’m running BuddyPress 1.9.1 now and it’s working smoothly. I think that you had some minor errors in your syntax though. Here’s the updated version:bp-custom
// Add meta fields upon group creation function bp_group_meta_save ( $group_id ) { $blog = get_blog_details( get_current_blog_id(), true ); $fields = array( 'blog_id' => $blog->blog_id, 'blog_path' => $blog->path, 'blog_name' => $blog->blogname ); foreach ( $fields as $field => $value ) { groups_update_groupmeta( $group_id, $field, $value ); } } add_action( 'groups_created_group', 'bp_group_meta_save' ); function get_groups_by_meta ( $field, $meta_key, $meta_value ) { global $wpdb; if ( is_string( $meta_value) ) $meta_value = "'" . $meta_value . "'"; $sql = $wpdb->prepare( "SELECT $field from {$wpdb->base_prefix}bp_groups_groupmeta WHERE meta_key='$meta_key' AND meta_value=$meta_value", OBJECT ); $res = $wpdb->get_results( $sql ); return $res; } // Build a list of groups with the matching blog_id value function get_groups_by_blogid ( $blog_id = 1 ) { $list = get_groups_by_meta( 'group_id', 'blog_id', $blog_id ); if ( count( $list ) ) { $res = ""; foreach ( $list as $item ) { $res .= $item->group_id . ','; } return substr( $res, 0, -1); } else { return FALSE; } }
groups-loop
<?php $current_blogid = get_current_blog_id(); if ( $current_blogid > 1) { $groups_set = get_groups_by_blogid( $current_blogid ); ( $groups_set !== FALSE ) ? $extra_args = '&include=' . $groups_set : $extra_args = '&include=-1'; } if ( bp_has_groups( bp_ajax_querystring( 'groups' ) . $extra_args ) ) : ?>