Forum Replies Created
-
Just in case anybody else needs this too, I have included an updated version of the code in form of a function. It now displays links to the groups a user is a member of and it’s possible to toggle display of hidden groups.
// display links to the groups a user is member of function user_group_memberships( $user_id = null, $show_hidden = false ) { $group_ids = groups_get_user_groups($user_id); $visible_group_ids = array(); foreach($group_ids["groups"] as $group_id) { if (!$show_hidden) { if(groups_get_group(array( 'group_id' => $group_id )) -> status !== 'hidden') { $visible_group_ids[] = $group_id; } } else { $visible_group_ids[] = $group_id; } } if (empty($visible_group_ids)) { echo 'None'; } else { foreach($visible_group_ids as $visible_group_id) { echo( '<a title="View group page" href="' . home_url() . '/groups/' . groups_get_group(array( 'group_id' => $visible_group_id )) -> slug . '">' . groups_get_group(array( 'group_id' => $visible_group_id )) -> name . '</a>' . (end($visible_group_ids) == $visible_group_id ? '' : ', ' ) ); } } }
This is my first ever PHP function so any feedback is welcome.
Thank you for your reply.
I did come across that thread earlier, but the answers didn’t seem to work for me.Anyway, I used the
groups_get_user_groups()
function you mentioned in your reply and came up with a solution doing what I was looking for along with comma separation of the group names:<?php $group_ids = groups_get_user_groups(bp_displayed_user_id()); foreach($group_ids["groups"] as $group_id) { echo(groups_get_group(array( 'group_id' => $group_id )) -> name . (end($group_ids["groups"]) == $group_id ? '' : ', ' ) ); } ?>
Does anyone else have anything to add?
I think I need to clarify that it’s the not being able to configure the WordPress profile in BuddyPress that I think is the issue. Displaying the fields is another side of it that I might agree should be left to a plugin developer.
…it will require keeping up with WP if they decide to switch which fields are included on that page.
I agree that this is an issue, but realistically, the WordPress profile hasn’t been updated in several years, apart from very recently when they actually removed fields in an effort to simplify it, so I doubt they intend to add anything to it either.
The fields at wp-admin/profile.php are very odd, and not appropriate for most BuddyPress installations…
As I mentioned above, those fields (AIM, Jabber and Yahoo/gTalk) were recently removed.
As noted in the ticket, First Name and Last Name are the two possible exceptions I see here.
That just leaves display name selection, nickname and website; email and password are configurable in BuddyPress and you already display username and bio on the profile when Extended Profiles are disabled. Why not allow the user to edit them too and add the remaining three fields? This would effectively move the profile to the front-end and nobody would need to configure their profile in two places again, which I think is the underlying issue here.
…it causes problems when other plugins add their own (hardcoded) fields, which BP won’t know about
I’m getting into deep water, but wouldn’t adding a hook before and/or after the fields be sufficient to deal with that?
Thank you for creating #5619, I’m gonna be glued to that ticket.
#3335 already has comments on it regarding why WP’s profile is not included with BuddyPress.
Sorry if I’m missing something, but all I can find are comments about a two-way sync where the issue is moving BuddyPress feature support upstream to the WordPress profile; I can’t find any arguments for not including the WordPress profile in BuddyPress.
About #4357, most bbPress profile pages already redirect to BuddyPress when it’s installed. Do you know if it’s bbPress or BuddyPress that’s doing the current overrides?
I guess I might as well add the details now.
My work so far has involved editing the bbPress and BuddyPress template files. I add the forms from the bbPress Edit page’s template file and paste them in the BuddyPress Settings page’s template file, which I then use.
My problem is that the data for the users profiles does not appear in the relevant bbPress Edit fields now that the forms reside on the BuddyPress settings page with a different URL.
I looked up how HTML forms work with PHP and found out that the
action
attribute in a<form>
tag is the URL for the destination of the input, so you might think that changing the URL of the bbPress forms to the BuddyPress Settings page would solve the problem, but it doesn’t.Doesn’t the user data need to be sent to and retrieved from the database somehow?
Thanks.
Thanks for the tip, tajenli.
Anyone reading this might also be interested in the following ticket on trac: #2062
Hi, did you figure it out?