Forum Replies Created
-
Hi @imath!
Interesting, I noticed the relation of those three entries were breaking the plugin/widget combination I was messing around with as a workaround. I ended up getting it to work by moving the code around in relation to those files. Took me forever though, lol. I am not a coder so have no clue what much of this stuff means but can move code around and tinker a bit.
Anyways, I just tested out the code snippet you provided and the issue no longer occurs! Is this just the way things have to arranged in order to display a member loop above the profile? Or should I still submit a bug report?
Thanks so much for looking into this. You guys are awesome!
Best!
mark@djpaul Hi Paul,
I have no clue what that means! Will copy my details from this ticket into a bug report when I get a chance. It’s 3:22AM so I will do so probably tomorrow.
So I just pieced some code from Buddypress 2.5.0 (previously used code from 2.4.0 files during testing) files together using class-bp-core-whos-online-widget.php and bp-members-widgets.php to create a generic widget containing a generic loop in it. After putting that generic widget into a dynamic sidebar and then calling that sidebar above the cover image header the loop displays and doesn’t break the private message button. Weird way about getting my custom loop to display above the cover image header on a member’s profile but works for some reason. Thought I’d let you know just in case the info helps.
Not sure why the code I pieced together from Buddypress 2.4.0 (bp-members-widgets.php) didn’t work also when I first tried this random workaround. During that round of testing the loop displayed as intended but still broke the private message button. I’m not a coder so I have no clue what is happening, I just figured it was something to do with the loading of the code so I tried random things to try and get it to work. Noticed you no longer just use bp-members-widget.php for 2.5.0 so maybe that has something to do with my workaround working now. Weird.
Anyways, thanks for all your help. Will be great to have one of you experts take a look and remedy this quirk.
Have a great night.
Regards,
markAwesome, thanks so much! Keep up the great work Paul.
Best!
markHey @djpaul!
Thanks for the quick reply. Basically I’d like to be able to include a clickable avatar of a member in the emails that are sent out instead of just an html link to their profile. Many community websites, online dating sites, etc., do this. For example, would be cool when a new member sends a friend request. Right now when a member friends another the default Buddypress email template includes a clickable link to visit the member’s profile ( {{initiator.name}} ). I think it would be sweet if there was a token ( e.g., {{initiator.avatar}} ) to use to give us the option to add the avatar.
Best!
MarkNot sure what I was going for before but using the below code seems to do the trick, and it outputs things in a more efficient manner. If anybody knows an even cleaner way to do this, please let me know.
<?php global $bp; $args = array( 'field' => 'Gender', 'user_id' => bp_loggedin_user_id() ); $gender = bp_get_profile_field_data($args); if ( $gender == "Female" ): echo 'female'; elseif ( $gender == "Male" ): echo 'male'; endif; ?>
Regards,
MarkHi @slaffik,
Just got home and did some additional testing. It is working! This ticket can be resolved. Thank you so much for all your help, really appreciate it.
Best Regards,
MarkHi @slaffik,
Replacing
$custom_ids_str = 'include=' . implode(",", $custom_ids);
with$custom_ids_str = implode(",", $custom_ids);
orreturn $custom_ids;
seems to have resolved my issue! I have to run out the door so I plan on doing more testing when I get home, but so far I believe it is working. After I get home and do some thorough testing I will let you know for sure if the issue is resolved. You rock man, really appreciate your help. Talk soon.Regards,
MarkHi @slaffik,
The code I am using on in my template is below. I am positive females are online as this is running on my local box and I have multiple female and male testing accounts that I am using for testing.
<?php $user_ids = my_custom_ids( 'gender', 'female' ); if ( bp_has_members( array( 'type' => 'online', 'include' => $user_ids ) ) ) : ?>
Also, I am using the following (taken from the codex) in my functions.php to get these custom ids to work, just in case you need this. And I have verified custom ids are in fact working.
function my_custom_ids( $field_name, $field_value = '' ) { if ( empty( $field_name ) ) return ''; global $wpdb; $field_id = xprofile_get_field_id_from_name( $field_name ); if ( !empty( $field_id ) ) $query = "SELECT user_id FROM " . $wpdb->prefix . "bp_xprofile_data WHERE field_id = " . $field_id; else return ''; if ( $field_value != '' ) $query .= " AND value = '" . $field_value . "'"; /* LIKE is slow. If you're sure the value has not been serialized, you can do this: $query .= " AND value = '" . $field_value . "'"; */ $custom_ids = $wpdb->get_col( $query ); if ( !empty( $custom_ids ) ) { // convert the array to a csv string $custom_ids_str = 'include=' . implode(",", $custom_ids); return $custom_ids_str; } else return ''; }
Really appreciate your help!
Best Regards,
Mark
Anybody else have any ideas as to why this function isn’t working?
Thanks!
Hi @slaffik,
Thank you for helping me. Unfortunately, tried th function and it did not work. Do you have any ideas?
Regards,
Mark
Hi @klame,
I am a newbie at all this too. I discovered that the function you pulled off Buddypress.org doesn’t have to be modified to work. You have to simply copy and paste it in your functions.php file as/is without changing a thing. What matters and needs to be modified is the php to render the members loop on your page (e.g.,
<?php if ( bp_has_members( my_custom_ids( 'location', 'san francisco' ) ) ) : ?>
). Adding href tags around it I don’t believe is the right idea. That code goes in your members loop where you want the members to be displayed matching that criteria. In my example I am showing only users in San Francisco. I’m pretty sure you can display the members loop anywhere you want but I haven’t tried that yet. I decided to create a page template and I simply copied the code out of my theme’s buddypress members-loop.php file and pasted it into the template file. You could probably even use the default WordPress members-loop.php file as your base, though if you have a theme you’re better off getting it out of there. I hope this helps. Good luck!No problem @henrywright, thank you for your help. My coding experience is nil so it has been an interesting experience as I have to Google around for everything. It’s great to have this forum which is full of code snippets to use/modify and experts like yourself to ask for help when I hit a wall. Thanks!
@henrywright Hi Henry, I was referring to this one:
if ( bp_is_groups_component() && bp_is_current_item( 'events' ) ) { // Code. }
I had to use
bp_is_current_action( 'events' )
in place ofbp_is_current_item( 'events' )
@henrywright Thanks Henry, unfortunately your function didn’t work either, however, you put me on the right track! Before speaking to you I had already sworn off
bp_is_groups_component()
. Interestingly enoughbp_is_current_action
is also needed alongside it to do what I need.Here’s what worked:
function wp_redirectauser() { if ( current_user_can('subscriber') && bp_is_groups_component() && bp_is_current_action( 'events' ) ) { wp_redirect( 'http://www.mywebsite.com/sales-page/' ); exit; } } add_action( 'wp', 'wp_redirectauser' );
@henrywright This conditional tag doesn’t seem to work for me. When a subscriber tries to access a specific tab within a group or their profile I want to redirect them to my sales page. I got this to work fine with the ‘events’ page on member profiles but not groups. Using
bp_is_groups_component()
redirects all group pages, not just the events page.Here’s the code I am using:
function wp_redirectauser() { if ( current_user_can('subscriber') AND bp_is_groups_component('events') ) { wp_redirect( 'http://www.mywebsite.com/sales-page/' ); exit; } } add_action( 'wp', 'wp_redirectauser' );
Any ideas on how to get this to work with just the ‘events’ group page? I’m new to all this so maybe I am just missing something in my function.
Best Regards,
Mark
@jscmal Interesting, thank you for providing this info. rtMedia recently upon my request for a new feature implemented privacy control for all activity stream items, not just rtMedia images shown on on the activity stream. This essentially allows rtMedia to replace the functionality of the (BuddyPress Activity Privacy plugin). I’m assuming you’ve noticed the option/dropdown on all activity stream updates to change the privacy. This is the reason I am chiming in on this for I was asked by them to report any bugs I’ve noticed. Probably a big code change on their end so I can see how there may be some bugs to work out. I couldn’t replicate this on my site so your best bet if still having this issue is to open a ticket with them. Good luck!
@jscmal Do you by chance have any theme customizations via custom functions that you’ve added to your child theme’s function.php or your bp-custom.php file? I have a lot and noticed some weird things happening after upgrade, albeit unrelated to your issue. You may want to activate and test your site on a WordPress default theme if you have custom functions and haven’t already tested on the default theme. Turned out I had some custom functions that weren’t optimally coded and I have since replaced them with new ones. Just a thought. Hope this helps. If not, be sure to submit a ticket at https://rtcamp.com/my-account/.
@jscmal Did you create a support ticket for this at: https://rtcamp.com/my-account/? I tried to replicate your issue but I couldn’t. Could be that I am not quite understanding the issue 100%.