Search Results for 'group_id'
-
AuthorSearch Results
-
September 12, 2014 at 8:37 am #192175
In reply to: Filter activities by friends and groups
richtelford
ParticipantHi @danbp. Okay so essentially what you are saying is I need to write a complex custom query?
I’ve been examining the Buddypress class and function files in detail over the last few weeks due to the lack of documentation for BuddyPress – not a criticism btw. Yep I’m familiar with meta_query and using that already to get groups by meta_value. I wrote a function for returning activity IDs based on group meta:
function wfw_get_group_activities_by_sport($sports = array()) { global $bp,$wpdb; if(!$sports) return false; // GET GROUP IDS WHICH HAVE CHOSEN SPORT SELECTED foreach($sports as $sport) { $meta_query[] = array( "key" => "group_sport", "value" => $sport, "compare" => 'LIKE' ); } if(count($meta_query) > 1) $meta_query = array_merge(array('relation' => 'OR'), $meta_query); $group_arr = BP_Groups_Group::get(array( 'per_page'=>-1, 'meta_query' => $meta_query )); if(!$group_arr['total'] || !$group_arr['groups']) return false; foreach($group_arr['groups'] as $group) { $group_id_array[] = $group->;id; } $item_id = implode(",", $group_id_array); $sql = "SELECT id FROM {$bp->activity->table_name} WHERE component = 'groups' AND item_id IN ({$item_id})"; $activity_id_array = $wpdb->get_col( $sql); if(!$activity_id_array) return false; $activity_id = implode(',', $activity_id_array); return $activity_id; }which I can then use to filter results:
$activity_id = wfw_get_group_activities_by_sport(array($_GET['sport'])); $filter = '&in='.$activity_id.'&object=groups'; if ($activity_id && bp_has_activities( bp_ajax_querystring( 'activity' ).$filter ) ) : ?>Now I just need to somehow combine what I’m using but it sounds like a complex query is the way to go. I was looking for a more elegant solution using BP functions to achieve this but I guess it’s not yet possible.
Anybody else have experience in this?
Thanks.
September 11, 2014 at 11:22 am #191888Roger Coathup
ParticipantCorrection — you can also use bp_group_name() by passing a group to it as its argument.
Take your group_id, instantiate a group, and pass it to bp_group_name():
$args = array( 'group_id' => $my_id ); $group = groups_get_group( $args ); .. bp_group_name( $group);September 1, 2014 at 8:01 pm #188883danbp
Participanthi @fumow,
here is a way to color any group activity on the site activity.
Group A is red, Group B is green.The function use the group ID and add a class to the existing. You can modify it in your child theme style.css file
Function can be installed in functions.php or bp-custom.php
function fumow_li_class_group_id( $class = '' ) { global $activities_template; // the group id in case of an activity in group component is the field item_id if ( buddypress()->groups->id == $activities_template->activity->component ) { $class .= ' rj-' . $activities_template->activity->item_id; } return $class; } add_filter( 'bp_get_activity_css_class', 'fumow_li_class_group_id', 10, 1 );You have to create a css class for each group. The example use group ID 13 and 9
li.groups.activity-item.rj-13 { background-color: #FFD5F4; } li.groups.activity-item.rj-9 { background-color: #be4; }References:
bp-activity-templatetags.phpMay this help !
August 25, 2014 at 11:44 pm #188486In reply to: [Resolved] Group Edit Dashboard broken
SeeingBlueS2
Participantbp_groups
id creator_id name slug description status enable_forum date_created 15 1 Twitch Network twitch-network Reserved for members of the Great Architect Twitch... private 1 2014-08-25 18:25:30bp_groups_groupmeta
id group_id meta_key meta_value 50 15 total_member_count 1 51 15 last_activity 2014-08-25 18:25:30 52 15 invite_status admins 53 15 forum_id a:1:{i:0;i:2683;} 54 15 _bbp_forum_enabled_2683 1bp_groups_members
id group_id user_id inviter_id is_admin is_mod user_title date_modified comments is_confirmed is_banned invite_sent 29 15 1 0 1 0 Group Admin 2014-08-25 18:25:18 1 0 0Everything looks ok in the database.
I also tried using the twentyfourteen theme and it didn’t help. Still not displaying the proper information in the dashboard under groups.
August 24, 2014 at 12:42 pm #188358Jencina
ParticipantSorry, not all is well.
I edit in my custom “register.php” , but I can’t see anything. This is the code of my register custom page:
<?php global $bp; if(empty($bp->signup->step)) $bp->signup->step=’request-details’; ?> <form action="” name=”signup_form” id=”signup_form” class=”standard-form” method=”post” enctype=”multipart/form-data”> <?php if ( 'registration-disabled' == bp_get_current_signup_step() ) : ?> <?php do_action( 'template_notices' ); ?> <?php do_action( 'bp_before_registration_disabled' ); ?> <p><?php _e( 'User registration is currently not allowed.', 'buddypress' ); ?></p> <?php do_action( 'bp_after_registration_disabled' ); ?> <?php endif; // registration-disabled signup setp ?> <?php if ( 'request-details' == bp_get_current_signup_step() ) : ?> <?php do_action( 'template_notices' ); ?> <p><?php _e( 'Registering for this site is easy. Just fill in the fields below, and we\'ll get a new account set up for you in no time.', 'buddypress' ); ?></p> <?php do_action( 'bp_before_account_details_fields' ); ?> <div class="register-section" id="basic-details-section"> <?php /***** Basic Account Details ******/ ?> <h4><?php _e( 'PRUEBA', 'buddypress' ); ?></h4> <label for="signup_username"><?php _e( 'Username', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label> <?php do_action( 'bp_signup_username_errors' ); ?> <input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" /> <label for="signup_email"><?php _e( 'Email Address', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label> <?php do_action( 'bp_signup_email_errors' ); ?> <input type="text" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" /> <label for="signup_password"><?php _e( 'Choose a Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label> <?php do_action( 'bp_signup_password_errors' ); ?> <input type="password" name="signup_password" id="signup_password" value="" /> <label for="signup_password_confirm"><?php _e( 'Confirm Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label> <?php do_action( 'bp_signup_password_confirm_errors' ); ?> <input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" /> <?php do_action( 'bp_account_details_fields' ); ?> </div><!-- #basic-details-section --> <?php do_action( 'bp_after_account_details_fields' ); ?> <?php /***** Extra Profile Details ******/ ?> <?php if ( bp_is_active( 'xprofile' ) ) : ?> <?php do_action( 'bp_before_signup_profile_fields' ); ?> <div class="register-section" id="profile-details-section"> <h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4> <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> <div class="editfield"> <?php $field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() ); $field_type->edit_field_html(); do_action( 'bp_custom_profile_edit_fields_pre_visibility' ); if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?> <p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?></a> </p> <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>"> <fieldset> <legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend> <?php bp_profile_visibility_radio_buttons() ?> </fieldset> <a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a> </div> <?php else : ?> <p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> </p> <?php endif ?> <?php do_action( 'bp_custom_profile_edit_fields' ); ?> <p class="description"><?php bp_the_profile_field_description(); ?></p> </div> <?php endwhile; ?> <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" /> <?php endwhile; endif; endif; ?> <?php do_action( 'bp_signup_profile_fields' ); ?> </div><!-- #profile-details-section --> <?php do_action( 'bp_after_signup_profile_fields' ); ?> <?php endif; ?> <?php if ( bp_get_blog_signup_allowed() ) : ?> <?php do_action( 'bp_before_blog_details_fields' ); ?> <?php /***** Blog Creation Details ******/ ?> <div class="register-section" id="blog-details-section"> <h4><?php _e( 'Blog Details', 'buddypress' ); ?></h4> <p><input type="checkbox" name="signup_with_blog" id="signup_with_blog" value="1"<?php if ( (int) bp_get_signup_with_blog_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes, I\'d like to create a new site', 'buddypress' ); ?></p> <div id="blog-details"<?php if ( (int) bp_get_signup_with_blog_value() ) : ?>class="show"<?php endif; ?>> <label for="signup_blog_url"><?php _e( 'Blog URL', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label> <?php do_action( 'bp_signup_blog_url_errors' ); ?> <?php if ( is_subdomain_install() ) : ?> http:// <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value(); ?>" /> .<?php bp_blogs_subdomain_base(); ?> <?php else : ?> <?php echo home_url( '/' ); ?> <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value(); ?>" /> <?php endif; ?> <label for="signup_blog_title"><?php _e( 'Site Title', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label> <?php do_action( 'bp_signup_blog_title_errors' ); ?> <input type="text" name="signup_blog_title" id="signup_blog_title" value="<?php bp_signup_blog_title_value(); ?>" /> <span class="label"><?php _e( 'I would like my site to appear in search engines, and in public listings around this network.', 'buddypress' ); ?>:</span> <?php do_action( 'bp_signup_blog_privacy_errors' ); ?> <label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_public" value="public"<?php if ( 'public' == bp_get_signup_blog_privacy_value() || !bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes', 'buddypress' ); ?></label> <label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_private" value="private"<?php if ( 'private' == bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'No', 'buddypress' ); ?></label> <?php do_action( 'bp_blog_details_fields' ); ?> </div> </div><!-- #blog-details-section --> <?php do_action( 'bp_after_blog_details_fields' ); ?> <?php endif; ?> <?php do_action( 'bp_before_registration_submit_buttons' ); ?> <div class="submit"> <input type="submit" name="signup_submit" id="signup_submit" value="<?php esc_attr_e( 'Complete Sign Up', 'buddypress' ); ?>" /> </div> <?php do_action( 'bp_after_registration_submit_buttons' ); ?> <?php wp_nonce_field( 'bp_new_signup' ); ?> <?php endif; // request-details signup step ?> <?php if ( 'completed-confirmation' == bp_get_current_signup_step() ) : ?> <?php do_action( 'template_notices' ); ?> <?php do_action( 'bp_before_registration_confirmed' ); ?> <?php if ( bp_registration_needs_activation() ) : ?> <p><?php _e( 'You have successfully created your account! To begin using this site you will need to activate your account via the email we have just sent to your address.', 'buddypress' ); ?></p> <?php else : ?> <p><?php _e( 'You have successfully created your account! Please log in using the username and password you have just created.', 'buddypress' ); ?></p> <?php endif; ?> <?php do_action( 'bp_after_registration_confirmed' ); ?> <?php endif; // completed-confirmation signup step ?> <?php do_action( 'bp_custom_signup_steps' ); ?> </form> </div> <?php do_action( 'bp_after_register_page' ); ?> </div><!-- #buddypress -->August 23, 2014 at 10:59 pm #188345danbp
ParticipantI was unable to get a correctly working form when i use the plugin page on the ADMIN tab. It shows only. So i revert back to get the job manager on a separate page who shows up on a group page.
The snippet is set for admins only and to work only on group ID 13 and 9.Anything is commented so you can modify that
Here a slightly modified version of my previous.
Install the plugin and use the shortcodes as indicated by the author and add the snippet to theme’s functions.php or bp-custom.phpfunction bpfr_add_page_to_group() { global $bp; if ( bp_is_active( 'groups' ) ) // allow oly admin's // this works also on single install if ( is_super_admin() ) : if ( class_exists( 'BP_Group_Extension' ) ) : class Job_Center_Group_Extension extends BP_Group_Extension { //building the tab function __construct() { $args = array( 'slug' => 'jobcenter', // tab slug - mandatory 'name' => 'Job Center', // tab name - mandatory //'parent_slug' => 'admin', ); parent::init( $args ); } // end construct() // content display function display() { // grab page or post ID $id = 240; $p = get_post($id); // output the post echo apply_filters('the_content', $p->post_content); } // end display() } // end class //display content only in one group (ex. group_ID is 14) // check for a group ID if( bp_has_groups() ) { // Grab current group ID bp_the_group(); $group_id = bp_get_group_ID(); } // apply our changes only to this group // conditionnal action if ( $group_id == 9 OR $group_id == 13 ) { bp_register_group_extension( 'Job_Center_Group_Extension' ); } endif; endif; } add_filter('bp_groups_default_extension', 'bpfr_add_page_to_group' );If you want to modify one of the plugin templates, make a copy of wp-job-manager/templates/ folder in your child theme and rename it job_manager ( ! no other name).
August 22, 2014 at 6:45 pm #188283shanebp
ModeratorInteresting thread.
This would be my approach:function bpfr_add_page_to_group() { if ( class_exists( 'BP_Group_Extension' ) ) : class Bongo_Group_Extension extends BP_Group_Extension { function __construct() { $args = array( 'slug' => 'bongo', 'parent_slug' => 'admin', 'nav_item_position' => 100, 'screens' => array( 'edit' => array( 'name' => 'Bongo', // the tab name ), ), ); parent::init( $args ); } function settings_screen( $group_id = NULL ) { // don't remove this function // = NULL is necessary to avoid Strict Standards warning } } // end of class bp_register_group_extension( 'Bongo_Group_Extension' ); endif; } add_filter('bp_groups_default_extension', 'bpfr_add_page_to_group' );Then, to avoid loading the form, create a template overload of
\buddypress\bp-templates\bp-legacy\buddypress\groups\single\admin.phpAnd add a conditional check of the action_variable.
Just before the form tag, add:<?php global $bp; if( $bp->action_variables[0] != 'bongo' ) : ?>Right after the form close tag, add:
<?php else : echo 'this is the bongo page'; endif; ?>Awkward, but seems to work.
The Group_Extension_API does need some work re making it easier to add tabs and tab counts.
I think the core devs are aware of this, but perhaps an enhancement ticket is in order?
@danbp
>The 1st function let you add custom content on the tab.
afaik – that function adds the content on every page under ‘Admin’.August 22, 2014 at 5:28 pm #188275danbp
ParticipantHi @nickpeplow,
it’s not possible to add sub nav items with the group API and the only other possibility that eventually could work a day (but not tomorrow 😉 ) would be
bp_core_new_subnav_item(), but it is a Todo, as stated in bp-groups-classes.php:3307Here are 2 snippets (i tested them within bp-custom.php – BP 2.0.2 Twentythirteen)
This one let you add some content on the new screen.
function add_admin_tab_content() { echo 'Quis scelerisque lacinia tempus nullam felis'; } add_action( 'groups_custom_edit_steps', 'add_admin_tab_content' );This one create a sub nav item when you’re on the group admin screen
function bpfr_add_page_to_group() { if ( class_exists( 'BP_Group_Extension' ) ) : class My_Custom_Group_Extension extends BP_Group_Extension { function __construct() { $args = array( 'slug' => 'houba-houba', 'parent_slug' => 'admin', // URL slug of the parent nav item 'nav_item_position' => 100, 'screens' => array( 'edit' => array( 'name' => 'Houba Houba', // the tab name ), 'create' => array( 'position' => 100, ), ), ); parent::init( $args ); } function settings_screen( $group_id ) { // don't remove this function } } // end of class bp_register_group_extension( 'My_Custom_Group_Extension' ); endif; } add_filter('bp_groups_default_extension', 'bpfr_add_page_to_group' );Once installed you will see that the “save change” button is still there. This button is contextual and cannot be removed, as it is used elsewhere. So you make it diseapear with the appropriate CSS with display:none!important; on the div with the ID of your/each group save button.
If you want to display that only for one group, you add a condition to
bp_register_group_extensionlike this} // end class //////////////////////////////////////////////////////////// /* display content only in one group (ex. group_ID is 14) */ //////////////////////////////////////////////////////////// // check for a group ID if( bp_has_groups() ) { // Grab current group ID bp_the_group(); $group_id = bp_get_group_ID(); } ////////////////////////////////////////// /* apply our changes only to this group */ ////////////////////////////////////////// // conditionnal action if ( $group_id == 14 ) { bp_register_group_extension( 'My_Custom_Group_Extension' ); }Voilà ! May this help.
More BP tips and tricks on my blog. (FR, sometimes EN – but php is always in english)
August 22, 2014 at 2:31 pm #188267In reply to: using placeholder attribute instead of label
mmadden
ParticipantYes, I’ve already edited the input fields within the basic-details-section div. I want to edit the input field in the profile-details-section div to match, but there is no input field in the register.php for that section. Instead there’s this:
<div class="register-section" id="profile-details-section"> <h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4> <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>Is there any way to get at the input tag that gets output to the profile-details-section?
August 21, 2014 at 9:09 pm #187770In reply to: using placeholder attribute instead of label
danbp
ParticipantHi @mmadden,
not sure i understand what you want to achieve. Are you creating a register page from scratch ?
Anyway….
Open the original BP register file (/buddypress/bp-templates/bp-legacy/buddypress/members/register.php). It contains many placeholders and conditionnalsSo, for the mandatory NAME xprofile group (the only one you use), you have line 65
if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); --- blah---Line 75 sit this placeholder
do_action( 'bp_custom_profile_edit_fields_pre_visibility' );where you can hook your additionnal information.Line 98 there’s another one:
do_action( 'bp_custom_profile_edit_fields' );just above this function:<p class="description"><?php bp_the_profile_field_description(); ?></p>In register.php, the section you speak about goes from line 50 to 112
From/***** Extra Profile Details ******/to</div><!-- #profile-details-section -->Of course, you can also add your own placeholder to your register template.
Sorry if i’m wrong.
August 10, 2014 at 8:53 pm #186399Hudson Atwell
ParticipantSo far this is as close as I have gotten:
public static function get_extended_fields( $user_id ) { $fields = array(); /* Get User Extended Data */ $r = bp_parse_args( $args['args'], array( 'profile_group_id' => 0, 'user_id' => $user_id ), 'bp_xprofile_user_admin_profile_loop_args' ); $i = 0; if ( bp_has_profile( $r ) ) { while ( bp_profile_groups() ) { bp_the_profile_group(); while ( bp_profile_fields() ) { bp_the_profile_field(); $field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() ); $fields[ $i ]['name'] = bp_get_the_profile_field_name(); $fields[ $i ]['id'] = bp_get_the_profile_field_input_name(); $fields[ $i ]['value'] = bp_get_the_profile_field_edit_value(); $i++; } } } return $fields; }July 25, 2014 at 11:17 am #185557In reply to: [Resolved] Display groups a user is member of
elaborate
ParticipantJust 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.
July 23, 2014 at 1:22 am #185437rcjr24
Participant@mercime I manage to rearrange all the fields using the code I posted, and now I have a code like this,
<?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1&hide_empty_fields=0' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> <?php if ( 'Country of Residence' == bp_get_the_profile_field_name() ) : ?> <select class="country-residence" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" placeholder="<?php _e( bp_the_profile_field_name().':' ); ?>"> <?php //bp_the_profile_field_options(); global $wpdb; $sql = "SELECT * FROM wp_country_list"; $results = $wpdb->get_results($sql) or die(mysql_error()); echo '<option data-value="holder-only" class="holder">Country of Residence:</option>'; foreach( $results as $result ) { echo '<option data-value="'. $result->three_letter_code .'" value="'. $result->three_letter_code .'">'.$result->name.'</option>'; } ?> </select> <?php do_action( bp_get_the_profile_field_errors_action() ); ?> <?php endif; ?> <?php endwhile; ?> <?php endwhile; endif; endif; ?>Now the problem is, when the registration completes, this field doesn’t reflect to the user profile after successful registration. Hope you’ve got my point here.
July 17, 2014 at 8:43 pm #185221In reply to: [Resolved] Display groups a user is member of
elaborate
ParticipantThank 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 ? '' : ', ' ) ); } ?>July 7, 2014 at 11:49 am #1848500bservator
ParticipantGuess I can check if the current group ID corresponds with the group I am in.
<?php // Let's say my group ID = 1 $exclude_admins_mods = (bp_get_group_id() == 1) ? 0 : 1; if (bp_group_has_members(array('exclude_admins_mods'=> $exclude_admins_mods))) : /* Member details */ endif; ?>July 7, 2014 at 11:20 am #1848480bservator
Participant<?php $args = array( 'group_id' => bp_get_group_id(), 'exclude_admins_mods'=> 0 ); ?>In the default groups loop:
<?php if (bp_group_has_members($args)) : ?> // member details <?php endif; ?>or when you use the groups_get_group_members() function:
<?php $groups_get_group_members = groups_get_group_members($args); ?>July 4, 2014 at 8:13 am #184797notpoppy
Participant@netweb. Thanks for the reply, glad to have helped identify a bug! I’m not sure it’s solved my problem however.
In my database in
bb_forumstheforums_idsare numbered 1 through to 50. And inwp_bp_groupsthe ids are numbered 1 through to 50. Group id 1 corresponds to forum id 1, group id 2 corresponds to forum id 2 and so on.However wp_bp_groups_groupmeta contains the following:
id group_id meta_key meta_value 1 1 last_activity 2014-02-27 10:56:36 2 1 total_member_count 2303 3 1 forum_id a:1:{i:0;i:127625;} 4 1 invite_status members 5 2 last_activity 2014-02-19 08:31:05 6 2 total_member_count 456 7 2 forum_id a:1:{i:0;i:127626;} 8 2 invite_status members 9 3 last_activity 2014-03-18 22:54:20 10 3 total_member_count 620 11 3 forum_id a:1:{i:0;i:127627;} 12 3 invite_status members 13 4 last_activity 2014-02-23 20:14:08 14 4 total_member_count 272 15 4 forum_id a:1:{i:0;i:127628;} 16 4 invite_status membersSo I’m not sure how those six-digit
meta_valuescorrespond to my forums.The group I’m having the problem with has
group_id26 and should be associated with the forum which has id 26, but instead is associated with 7. As you’d expect based on the above its value is a:1:{i:0;i:127650;}Is there somewhere else in the database where these longer values are connected to the correct
forum_ids? As I say I’ve been looking but not found anything obvious.July 4, 2014 at 6:07 am #184795Stephen Edgar
ModeratorIt looks like there is a bug in bbPress’ repair tool 🙁
If you grab the bbPress forum ID e.g.
25Open up
wp_bp_groups_groupmetaYou should see something similar to this:
id group_id meta_key meta_value 1 1 total_member_count 2 2 1 last_activity 2014-06-26 00:37:33 3 1 invite_status members 4 2 total_member_count 1 5 2 last_activity 2013-11-03 10:35:12 6 2 invite_status members 7 3 total_member_count 1 8 3 last_activity 2013-11-03 10:37:53 9 3 invite_status members 10 1 forum_id a:1:{i:0;i:25;} 11 2 forum_id a:1:{i:0;i:27;} 12 3 forum_id a:1:{i:0;i:29;}So for group group ID
1the bbPress forum ID25is stored asa:1:{i:0;i:25;}(serialized array), thus change the25to the correct bbPress forum ID you need.I’ll go write up a fix for bbPress repair tools for the next release 🙂
July 3, 2014 at 6:39 am #184763In reply to: How to have a Dynamic xProfile field?
dzung
ParticipantTo anyone who want the same thing, follow my below steps.
I have a text file contains about 600+ names of schools and I want to make a schools-drop-down – So It’s very time-consuming to click add option one by one. It needs another way:
1. Content of The Schools list text file.
Tamale Polytechnic
Kumasi Polytechnic
Accra Polytechnic
Cape Coast Polytechnic
Koforidua Polytechnic
Ho Polytechnic
….600+…
2. I go to xProfile and create a Drop-down named it Schools – I input one option say “A sample school” – save.
3. I go to phpMyadmin -to Database to table gsl_bp_xprofile_fields – Search “A sample school” to find the newly created Sample schools row – on the result look at the
columns: (group_id, parent_id, type , name) . they should have values like: (group_id: 1, parent_id: 127,type :’option’ ,name :’A sample school’).
4. Next I use a Core Java code(because I don’t know how to do this in PHP) to read the schools list text file one by one and custom the print out like this:String fileName = "D://Schools.txt"; String line = null; try { FileReader fileReader = new FileReader(fileName); BufferedReader bufferedReader = new BufferedReader(fileReader); while((line = bufferedReader.readLine()) != null) { line = line.replace("'", ""); String sqlBase = "INSERT INTO gsl_bp_xprofile_fields (group_id,parent_id, type,name) VALUES (1, 127,'option' ,"+"'"+line+"'"+");"; System.out.println(sqlBase); } bufferedReader.close(); }After running the above code I have a list of SQL insert commands printed on my eclipse they look like this:
INSERT INTO gsl_bp_xprofile_fields (group_id,parent_id, type,name) VALUES (1, 127,'option' ,'Tamale Polytechnic'); INSERT INTO gsl_bp_xprofile_fields (group_id,parent_id, type,name) VALUES (1, 127,'option' ,'Kumasi Polytechnic'); INSERT INTO gsl_bp_xprofile_fields (group_id,parent_id, type,name) VALUES (1, 127,'option' ,'Accra Polytechnic');….many more insert commands until the end of the schools file 600+
5. Next, I copy all these commands, come back phpMyadmin database- table gsl_bp_xprofile_fields – to SQL tab, paste all commands, click run/go to insert all the options.
That’s all done for me!
June 25, 2014 at 6:58 pm #184407In reply to: How to display static text as a profile field?
nhalation
ParticipantWell, with a bit more Googling I’ve gotten this solved for the most part. I know these pages get indexed so here’s what I did for anyone’s future reference. For this example’s sake I’ll just cover the “Member Since” field.
– Created a copy of profile-loop.php in the appropriate child theme directory for update-safe modification.
– In the child copy of profile-loop.php, right beneath
<?php do_action( 'bp_after_profile_field_content' ); ?>, which is inside (and at the bottom) of the ‘if ( bp_profile_group_has_fields())’ if check, I put the following code to output this field for the base group only (assuming the base group has an ID of 1):<?php if ( bp_get_the_profile_group_id() == 1 ) : ?> <table class="profile-fields"> <tr<?php bp_field_css_class(); ?>> <td class="label">Member Since</td> <td class="data"><?php bp_custom_profile_fields(); ?></td> </tr> </table> <?php endif; ?>And then finally, in my child theme’s functions.php file (this could probably also go in bp-custom.php) I found and pasted this code to define and format the join date:
function bp_custom_profile_fields() { global $bp; $currentuser = get_userdata( $bp->displayed_user->id ); $joined = date("F jS, Y", strtotime($currentuser ->user_registered)); echo '' . $joined . ''; }June 22, 2014 at 11:27 pm #184324In reply to: [Resolved] Showing posts by groups
kypto
Participantthx, but could you help me with that loop? i understand that query thinq, however im not very good at java and cant figure out how to make the loop for members ids work. the goal should be to get the string like “id,id,id” (in order to use it at the query – author=string),but i dont know how to get it from that goups_get_group_member function.
and one more thing, in documentation there is that the group_id is taken from currect groud (if i get it right :D), but i need it to be from any group i choose.
May 18, 2014 at 8:28 pm #183094In reply to: Avatar of group in MySql Database
shanebp
ModeratorIt’s not stored in the database.
It’s in /wp-content/uploads/group-avatars/[group_id]/[…bpthumb or bpfull]
May 15, 2014 at 1:56 pm #182956In reply to: [Resolved] Showing posts by groups
David Cavins
KeymasterSure. You’ll need a to make a loop in which you get the ids of the group members and then create a query to fetch those posts.
For getting group member ids, look at:
groups_get_group_members( $args = array( $group_id => # ) )For the query by author ids: https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
May 12, 2014 at 9:07 pm #182805In reply to: show profile data in specific groups
olafnekeman
ParticipantThanks for your input!!!!
i’ve got it working now!
for anyone who’s having trouble with the same issue, here the code:<?php if( bp_get_group_id() == 5){ if ( xprofile_get_field_data( 'Jouw 06', $user_ID ) ) : echo xprofile_get_field_data( 'Jouw 06', $user_ID ); endif; }May 12, 2014 at 8:57 pm #182804In reply to: show profile data in specific groups
shanebp
ModeratorTry
if( bp_get_group_id() == 5 ) or if( bp_get_group_id() == '5' ) -
AuthorSearch Results