Search Results for 'group_id'
-
AuthorSearch Results
-
January 10, 2013 at 8:13 pm #150184
In reply to: [Resolved] Show Group Member List on Group Directory
DKerrigan
ParticipantThanks again for the help @shanebp.
Here is a copy of the code in question: http://pastebin.com/J5sEfVNt
When I hard code a group_id into Line 15, I can see members appear. However, I need it to be dynamic, as I want each group to show all members.
January 10, 2013 at 7:07 pm #150165In reply to: [Resolved] Show Group Member List on Group Directory
shanebp
ModeratorYou don’t say where you tried to use bp_group_has_members().
In a function you probably need a global or two, at least global $bp;
Try hard coding a group_id into your bp_group_has_members() call.
If that works, then you have to dig around and find the right globals and calls to make.
( maybe bp_get_current_group_id() ? )If it doesn’t work, there could be an issue with your setup or maybe you can’t use multiple
bp_group_has_members calls in the same parent loop.
According to the codex, the latter shouldn’t be an issue, but… ?
https://codex.buddypress.org/developer/developer-docs/loops-reference/the-group-members-loop-bp_group_has_members/
“The ID of the group to fetch members for. Required when… not nested within a bp_has_groups() loop.January 10, 2013 at 6:13 pm #150159In reply to: [Resolved] Show Group Member List on Group Directory
DKerrigan
ParticipantThanks for the quick reply @shanebp.
I tried using:
`if ( bp_group_has_members() )`However, when I check out the Groups directory, each group has the message “This group has no members”. Is there any way to pass the group_id to bp_group_has_members() without hard coding it?
January 2, 2013 at 9:47 pm #149490In reply to: Database Error
fpats
ParticipantHere’s one of many errors we get, this one is currently showing in the sidebar Groups widget..
WordPress database error: [Out of memory (Needed 12582880 bytes)]
SELECT COUNT(DISTINCT g.id) FROM wp_bp_groups g, wp_bp_groups_members gm1, wp_bp_groups_groupmeta gm2 WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = ‘last_activity’With VPS.net
December 14, 2012 at 5:43 pm #147392In reply to: New XProfile Field With A Loop
TripWest
ParticipantAlright, here’s where I am at. However, it seems to be riddled with errors. Anybody see anything glaringly wrong with my plugin? I’m getting parsing errors around line 7
1,
‘type’ => ‘selectbox’,
‘name’ => ‘Featured Teacher’,
‘description’ => ‘Showcase your teacher on your Profile’,
‘is_required’ => false,
‘can_delete’ => true,
‘order_by’ => ‘name’
);
$featured_teacher_list_id = xprofile_insert_field($teacher_list_args);
if ($featured_teacher_list_id) {
$featured_teachers = array(while ( bp_members() ) : bp_the_member();
$fitlinkzmembertype = xprofile_get_field_data(‘Member Type’, bp_get_member_user_id());
if ($fitlinkzmembertype == ‘Teacher’) :
bp_member_name();
endif;
endwhile;);
foreach ($featured_teachers as $i =>$featured_teacher) {
xprofile_insert_field(array(
‘field_group_id’ => 1,
‘parent_id’ => $featured_teacher_list_id,
‘type’ => ‘selectbox’, // it is ‘selectbox’ not ‘option’
‘name’ =>$featured_teacher,
‘option_order’ => $i+1
));
}
}
}//Featured Group
add_action(‘bp_member_meta_init’, ‘featured_group_list’); // That might not be the perfect hook to use
function featured_group_list() {
if (xprofile_get_field_id_from_name(‘Featured Group’)) return;
$group_list_args = array(
‘field_group_id’ => 1,
‘type’ => ‘selectbox’,
‘name’ => ‘Featured Group’,
‘description’ => ‘Showcase your group on your Profile’,
‘is_required’ => false,
‘can_delete’ => true,
‘order_by’ => ‘name’
);
$featured_group_list_id = xprofile_insert_field($group_list_args);
if ($featured_group_list_id) {
$featured_groups = array(while ( bp_groups() ) : bp_the_group(); if(custom_field(‘fitlinkz-group-type’) == ‘Group’ ) :
bp_group_name();
endif;
endwhile;);
foreach ($featured_groups as $i =>$featured_group) {
xprofile_insert_field(array(
‘field_group_id’ => 1,
‘parent_id’ => $featured_group_list_id,
‘type’ => ‘selectbox’, // it is ‘selectbox’ not ‘option’
‘name’ =>$featured_group,
‘option_order’ => $i+1
));
}
}
}?>
December 3, 2012 at 8:15 am #146393Vicky A M R
Participantwell, worked , Thanks @rogercoathup
November 30, 2012 at 5:52 am #146182pbarnhart
ParticipantStart with:
<?php $formloop = 0; ?>
<?php if ( bp_is_active( ‘xprofile’ ) ) : if ( bp_has_profile( ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
<?php
if (bp_get_the_profile_group_id() != $formloop) {
$formloop = bp_get_the_profile_group_id();
$newfieldset = TRUE;
?>
<fieldset id="xprofile_<?php echo bp_get_the_profile_group_slug() ?>">
<legend><?php echo bp_get_the_profile_group_name() ?></legend>
<?php
}
?>
<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
<?php$formlist[] = bp_get_the_profile_field_id(); ?>—– Continue with the form code —-
<?php endwhile; ?>
<?php
if ($newfieldset == TRUE) {
$newfieldset = FALSE;
?>
</fieldset>
<?php
}
?>
<?php endwhile; endif; endif; ?>
<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php echo implode(",", $formlist); ?>" />November 29, 2012 at 5:07 pm #146122Roger Coathup
ParticipantAs I said previously, the group_id is passed as the first parameter to the action.
You need to add the parameters to your function.
If you are not familiar with writing action functions in WordPress, you should read here: https://codex.wordpress.org/Function_Reference/add_action
November 29, 2012 at 12:40 pm #146113Vicky A M R
ParticipantThanks @roger , All know that without having the group_id , no one canot perform the ‘groups_join_group’ , But I need this group_id as follows,
function get_group()
{
return group_id();
}
add_action(‘groups_join_group’,’get_group’);
I need the get_group() function should return the group_id where it is hooked into ‘groups_join_group’ as add_action.
@Roger you can try more 🙂
Does any one can get this 🙂 thanks
November 29, 2012 at 10:00 am #146095Roger Coathup
ParticipantThe groups_join_group action gets passed the group_id as its first parameter:
e.g. do_action( ‘groups_join_group’, $group_id, $user_id );
So, you have the group_id already.
Interestingly, there doesn’t seem to be a function to get the creator – so, you would then either have to:
Create a new BP_Group instance using the group_id, and directly access the it’s ->creator_id attribute, or
Make a direct SQL call on $bp->groups->table_name to return the creator_id where the id = group_idOctober 24, 2012 at 5:42 pm #143906evagorasc
ParticipantAha. Problems.
So, following the advice of @modemlooper I got this working just fine. Anything created under Buddypress custom user fields can display fine in the bbPress loops, using something like this:
`
$user_location = xprofile_get_field_data( ‘Location’, bbp_get_reply_author_id() ) ;
if (strlen($user_location) > 0 ) :
echo ‘Location: ‘ . $user_location . ‘
‘;
endif;
`However, how do I make sure I follow the custom fields’ restrictions regarding visibility? In BuddyPress we can create a custom field and set its visibility to be either:
1) Anyone
2) Logged In Users
3) My FriendsFurthermore, these fields’ visibility can be allowed to be changed by each user.
So, before simply displaying a custom field for just everyone, I need to run the required checks to verify that it should be displayed for the anonymous/logged-in user. I tried getting a reference to the actual field, like this but the var_dump() doesn’t help me much:
`$user_location_field = xprofile_get_field( ‘Location’, bbp_get_reply_author_id() ) ;`
This is the var_dump($user_location_field):
`object(BP_XProfile_Field)[29]
public ‘id’ => null
public ‘group_id’ => null
public ‘parent_id’ => null
public ‘type’ => null
public ‘name’ => null
public ‘description’ => null
public ‘is_required’ => null
public ‘can_delete’ => null
public ‘field_order’ => null
public ‘option_order’ => null
public ‘order_by’ => null
public ‘is_default_option’ => null
public ‘default_visibility’ => null
public ‘allow_custom_visibility’ => string ‘allowed’ (length=7)
public ‘data’ => null
public ‘message’ => null
public ‘message_type’ => string ‘err’ (length=3)`Even though I see a couple of public methods like “default_visibility()” and “allow_custom_visibility()”, they don’t really help. Their value doesn’t even change even when I change the field properties in the CMS.
October 6, 2012 at 2:47 pm #143070In reply to: Custom groups loop with groups meta
Anonymous User 96400
InactiveRather than doing two loops, one of which will run through all available groups to perform a database request each time, just do 1 query that gets all group ids and then pass those ids to the include parameter. Something like this:
`function my_get_groups_for_country( $country = ” ) {
global $wpdb, $bp;$group_ids = $wpdb->get_col( $wpdb->prepare( “
SELECT group_id
FROM {$bp->groups->table_name_groupmeta}
WHERE meta_key = ‘group-country’
AND meta_value = %s
“, $country ) );return $group_ids:
}`October 6, 2012 at 2:40 pm #143069In reply to: Custom groups loop with groups meta
shanebp
ModeratorMaybe something like this – untested:
`
$group_ids = $wpdb->get_var(“SELECT id FROM groups_groupmets WHERE meta_key = ‘group-country’ AND meta_value = ‘Russia'”);foreach ( $group_ids as $group_id ) {
$group_ids_str[] = $group_id->id”;
}
$theIncludeString = implode (‘,’, $group_ids_str);if( !empty($theIncludeString) ) // build args and start loop
else … ?
`October 3, 2012 at 1:25 am #142909agtd
ParticipantFinally sorted something out.
==========================================================================
Add the following to your edit.php file:
`<?php if(bp_get_current_profile_group_id()==2)
> //change this to the group id you want to restrictThese field have been locked by the Administrator. //or whatever you want to say
`
==========================================================================
Fix this line to include the “<?php" before the if like so:
`<?php if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() ) ) :`==========================================================================
insert this to the second last line:
“==========================================================================
September 24, 2012 at 3:53 pm #142354frank tredici
MemberTried `bp_group_id()` — no luck.
September 24, 2012 at 3:49 pm #142353modemlooper
Moderatordid you try
`bp_group_id()`
In BP most get functions are wrapped if you looked at the function bp_group_id() it would echo the value of bp_get_group_id()
September 24, 2012 at 3:42 pm #142352frank tredici
Member`
if (groups_is_user_mod( get_current_user_id(), $guid ) == “1”) return;
elseif (groups_is_user_admin( get_current_user_id(), $guid ) == “1”) return;
else …
`Everything else works — `groups_is_user_mod()`, `groups_is_user_admin()`, and `get_current_user_id()`.
Right now I have hardcoded the Group ID and assigned it to var $guid. But I want to do this dynamically so I don’t have to manually hardcode certain group ids.
Here’s what I want to get to work:
`
if (groups_is_user_mod( get_current_user_id(), bp_get_group_id() ) == “1”) return;
elseif (groups_is_user_admin( get_current_user_id(), bp_get_group_id() ) == “1”) return;
`Thanks for helping !
September 24, 2012 at 3:07 pm #142347frank tredici
MemberThanks @modemlooper.
My question is not how to display it. My question is how to capture it.
Currently I assign it to a variable like this `$guid = bp_get_group_id();`
The problem is that while I am in the loop of groups & discussions, the current group id is not being captured. `bp_get_group_id()` returns an empty string or NULL.
Also, I issued a bug report on it as well.
September 21, 2012 at 11:23 am #142219In reply to: What is the command to get the current group id?
frank tredici
MemberAny experts or specialists or experienced BuddyPress types out there that know how to capture the `$group_id` so I can use it in the following?
`groups_is_user_mod( $user_id, $group_id )`
Is it even possible?
September 21, 2012 at 11:23 am #142218In reply to: Is there a function call is_group_mod() ?
frank tredici
MemberAny experts or specialists or experienced BuddyPress types out there that know how to capture the `$group_id` so I can use it in the following?
`groups_is_user_mod( $user_id, $group_id )`
Is it even possible?
September 20, 2012 at 6:04 pm #142172In reply to: Is there a function call is_group_mod() ?
frank tredici
MemberFound it
`groups_is_user_mod( $user_id, $group_id )`But now I need to find out how to capture the current group id. Right now I am hard coding it and I don’t want to do it that way.
Does anyone know how to retrieve the current Group ID?
September 12, 2012 at 8:21 am #141506In reply to: Create custom field in ’base’ group manually
drrxa
ParticipantI have a working code now, the following code is able to insert a select box profile field to the ‘base’ group with any long list of options that might be hard to insert manually through the user interface. this specific example will insert a profile field with the title of “Country” that contains all countries as options. Use this code in your `functions.php` or `bp-custom.php` file and you will notice a new profile field with the title of “Country” the next time you visit the Base group in Profile Fields admin area. You can then update and change the options to suit your needs and after that click “Save” button to register this field.
Be aware that the following code will not add a new “Country” profile field as long as a profile field with the title of “Country” already exists, meaning that if you change the title to “List of Countries” for example, it will add a new profile field with the title of “Country” to your profile field, so I think it is better to use this code only once and whenever you need to insert a long listed profile field, and then remove the code from `functions.php` or `bp-custom.php` and keep on other place for future use.
`
add_action(‘bp_init’, ‘add_custom_country_list’); // That might not be the perfect hook to use
function add_custom_country_list() {
if (xprofile_get_field_id_from_name(‘Country’)) return;
$country_list_args = array(
‘field_group_id’ => 1,
‘type’ => ‘selectbox’,
‘name’ => ‘Country’,
‘description’ => ‘Please select your country’,
‘is_required’ => true,
‘can_delete’ => false,
‘order_by’ => ‘default’
);
$country_list_id = xprofile_insert_field($country_list_args);
if ($country_list_id) {
$countries = array(‘USA’,’Germany’,’England’); // Google for “country list php” and replace this one
foreach ($countries as $i => $country) {
xprofile_insert_field(array(
‘field_group_id’ => 1,
‘parent_id’ => $country_list_id,
‘type’ => ‘selectbox’, // it is ‘selectbox’ not ‘option’
‘name’ => $country,
‘option_order’ => $i+1
));
}
}
}
`September 8, 2012 at 12:22 pm #141281In reply to: Create custom field in ’base’ group manually
drrxa
ParticipantMy specific problem is that I need to add a country select box to the extended user profile that will appear in registration form and I don’t want to add it through the admin panel because (1) it is hard to enter 256 countries manually and (2) I will need multiple instances of that list.
Now I came up with the following code after a while of digging into the core files of BuddyPress, the first part that add the ‘Country’ `selectbox` works fine, but the second part which is supposed to add the countries options does not wok, I get an empty `selectbox` that is labeled “Country” without any options:
`
add_action(‘bp_init’, ‘add_custom_country_list’); // That might not be the perfect hook to use
function add_custom_country_list() {
if (xprofile_get_field_id_from_name(‘Country’)) return;
$country_list_args = array(
‘field_group_id’ => 1,
‘type’ => ‘selectbox’,
‘name’ => ‘Country’,
‘Description’ => ‘Please select your country’,
‘is_required’ => true,
‘can_delete’ => false,
‘order_by’ => ‘default’
);
$country_list_id = xprofile_insert_field($country_list_args); // It work till here – The following part does not work
if ($country_list_id) {
$country_list = array(‘USA’,’Germany’,’England’); // To be replaced with the full country list
foreach ($country_list as $i => $country) {
xprofile_insert_field(array(
‘field_group_id’ => 1,
‘parent_id’ => $country_list_id,
‘type’ => ‘option’,
‘name’ => $country,
‘option_order’ => $i+1
));
}
}
}
`
Can anyone help me about what is wrong with this code? Thanks.August 15, 2012 at 9:20 am #139502In reply to: [Resolved] Wrapping Secondary avatar with link
Jonathan
MemberFor anyone who may find this,and is looking to do what I did here is the code:
`function bbg_turn_secondary_avatars_to_links( $avatar ) {
global $activities_template;switch ( $activities_template->activity->component ) {
case ‘groups’ :
$item_id = $activities_template->activity->item_id;
$group = groups_get_group( array( ‘group_id’ => $item_id ) );
$url = apply_filters( ‘bp_get_group_permalink’, trailingslashit( bp_get_root_domain() . ‘/’ . bp_get_groups_root_slug() . ‘/’ . $group->slug . ‘/’ ) );
break;
case ‘blogs’ :
break;
case ‘friends’ :
$item_id = $activities_template->activity->secondary_item_id;
$url = bp_core_get_user_domain($item_id);
break;
default :
break;}
if ( !empty( $url ) ) {
$avatar = ‘‘ . $avatar . ‘‘;
}
return $avatar;
}
add_filter( ‘bp_get_activity_secondary_avatar’, ‘bbg_turn_secondary_avatars_to_links’ );`August 14, 2012 at 5:31 pm #139438In reply to: [Resolved] Wrapping Secondary avatar with link
Boone Gorges
KeymasterI’m looking over the code, and there’s not a very easy way to make it happen. We have hooks in bp_get_activity_secondary_avatar(), but we’re not passing along enough information to make it possible for filters to make the avatars linkable.
Could I ask you to open an enhancement ticket at https://buddypress.trac.wordpress.org/ explaining what you’re trying to do? I can make sure that the filters are improved to make what you’re trying to do possible.
In the meantime, it’s possible to do what you want, though not elegant. Here’s a hint:
`
function bbg_turn_secondary_avatars_to_links( $avatar ) {
global $activities_template;// Here you’ll copy the logic in bp_get_activity_secondary_avatar() to switch between types
switch ( $activities_template->activity->item_id ) {
// Here’s an example of what to do with groups
case ‘groups’ :
$group_id = $activities_template->activity->item_id;
$group = groups_get_group( $group_id );
$url = bp_get_group_permalink( $group );
break;// You’ll have to do similar sorts of tricks for different content types
}// Then, wrap the avatar in a URL
if ( !empty( $url ) ) {
$avatar = ‘‘ . $avatar . ‘‘;
}return $avatar;
}
add_filter( ‘bp_get_activity_secondary_avatar’, ‘bbg_turn_secondary_avatars_to_links’ );
`This may not work as is (it’s off the top of my head) but it should give you a push in the right direction. Good luck!
-
AuthorSearch Results