Search Results for 'group_id'
-
AuthorSearch Results
-
July 20, 2013 at 3:35 pm #168425
In reply to: bbp_has_topics – hide topics from private grou
David Cavins
KeymasterPut this before the code we’ve been talking about, and see what it displays on the page:
$test_id = bp_get_current_group_id(); echo 'The current group ID is:' . $test_id;If it returns a number besides zero (zero means that it can’t figure out which group is the current group, a non-zero number is the current group ID), then you could probably adjust the conditional code:
if ( bp_group_is_visible( bp_get_current_group_id() ) ) { //do the topics loop here }Fingers crossed.
July 20, 2013 at 3:25 pm #168423In reply to: bbp_has_topics – hide topics from private grou
nando99
Participantit doesnt work as in: no posts show up at all :/
it is on the sidebar… how would i pass the group_id and give bbp_topics access… pretty much a noob here, sorry…
thanks in advance!
July 20, 2013 at 12:03 am #168383In reply to: bbp_has_topics – hide topics from private grou
David Cavins
KeymasterWhen you say it didn’t work, do you mean that people who should see the topics couldn’t, or that no one could see the topics, or that everyone could see the topics? Was it too generous in letting people through or did it keep everyone out? 😉
Also, could it be that this is this being used in a sidebar? I’m wondering if the placement on the page means that the group context is not certain, so you’d need to pass the group_id into
bp_group_is_visible. Although I’d expect thebbp_topicsto need to access the group_id as well.July 14, 2013 at 2:29 pm #168061In reply to: Adding custom HTML to each profile group tab
MakeNice
ParticipantThink I have figured out how best to work this. For anyone that may need it sometime the code I used was:
<?php if ( 1 == bp_get_the_profile_group_id()) : ?> <h4>About Me</h4> <?php endif; ?>With 1 == the profile tab where I need to add my custom HTML. If anyone has alternative solutions I’m happy to hear them.
July 2, 2013 at 1:02 pm #167414In reply to: Adding group ID to activity lists
Shmoo
ParticipantFound the answer by reading this topic.
https://buddypress.org/support/topic/how-to-get-group-id-while-in-activity-loop-php/The word item_id got me thinking-/searching in the Core files before I found this tag.
<?php bp_activity_item_id(); ?>– It will Echo just a plain ID number of the related Group the activity is posted in. Just what I needed, I maybe was too focused on the word ‘group’ and searching to much about group_id’s.
June 19, 2013 at 6:17 pm #166414In reply to: Replace BuddyPress profile with custom profile
modemlooper
ModeratorYou can hide fields from being edited easy. in members/single/edit.php you can exclude fields by ID. Use comma separated list.
if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() . '&exclude_fields=2,3,4' ) ) :full code example https://gist.github.com/modemlooper/5816548
June 10, 2013 at 5:24 pm #165710In reply to: Duplicate profile field names
Henry
MemberI may be wrong but
echo bp_get_profile_field_data( 'field=Email' )won’t necessarily echo the “Email” field in profile group 2. Allif ( bp_has_profile('profile_group_id=2') )does is check if profile group 2 exists.June 10, 2013 at 5:06 pm #165707In reply to: Duplicate profile field names
danbp
ParticipantHi @henrywright-1,
i guess you can also filter by group profile ID
<?php if ( bp_has_profile('profile_group_id=2') ) : echo bp_get_profile_field_data( 'field=Email' ) endif; if ( bp_has_profile('profile_group_id=45') ) : echo bp_get_profile_field_data( 'field=Email' ) endif; ?>June 9, 2013 at 10:37 am #165654In reply to: Add Custom Setting to Buddypress Settings
P
ParticipantThe problem is I need to modify the core files and add a plugin at the same time so a user can change the Throttling settings in his WordPress backend.
I really tried to simple write a plugin and skip the core files modifications, but it’s just not working out. Maybe you can help out here, I will post the 3 core file functions which I modified as well as the plugin code which I wrote. If you can figure out a way for me to not modify the core files and still get Throttling to work, share your code.
Modified files:
1- bp-activity\bp-activity-functions.php
function bp_activity_post_update( $args = '' ) { global $bp; $defaults = array( 'content' => false, 'user_id' => bp_loggedin_user_id() ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( empty( $content ) || !strlen( trim( $content ) ) ) return false; if ( bp_is_user_inactive( $user_id ) ) return false; <strong>$floodTest = bp_core_check_for_flood ($user_id); if (!$floodTest) return "flood";</strong> // Record this on the user's profile $from_user_link = bp_core_get_userlink( $user_id ); $activity_action = sprintf( __( '%s posted an update', 'buddypress' ), $from_user_link ); $activity_content = $content; $primary_link = bp_core_get_userlink( $user_id, false, true ); // Now write the values $activity_id = bp_activity_add( array( 'user_id' => $user_id, 'action' => apply_filters( 'bp_activity_new_update_action', $activity_action ), 'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ), 'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ), 'component' => $bp->activity->id, 'type' => 'activity_update' ) ); $activity_content = apply_filters( 'bp_activity_latest_update_content', $content ); // Add this update to the "latest update" usermeta so it can be fetched anywhere. bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array( 'id' => $activity_id, 'content' => $content ) ); do_action( 'bp_activity_posted_update', $content, $user_id, $activity_id ); return $activity_id; }2- bp-core\bp-core-moderation.php
function bp_core_check_for_flood( $user_id = 0 ) { <strong>// Option disabled. No flood checks. if ( !$throttle_time = bp_get_option( 'bt_activity_time' ) ) return false; // Bail if no user ID passed if ( !$user_id ) return false; $last_posted = get_user_meta( $user_id, '_bp_last_posted', true ); if ( !$last_posted ) { $last_posted = time(); add_user_meta( $user_id, '_bp_last_posted', $last_posted); return true; } else { if ( ( time() < ( $last_posted + $throttle_time ) ) && !current_user_can( 'throttle' ) ) { update_user_meta($user_id,'_bp_last_posted',time()); return false; } else { update_user_meta($user_id,'_bp_last_posted',time()); return true; } }</strong> }3- bp-themes\bp-default\_inc\ajax.php
function bp_dtheme_post_update() { // Bail if not a POST action if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) return; // Check the nonce check_admin_referer( 'post_update', '_wpnonce_post_update' ); if ( ! is_user_logged_in() ) exit( '-1' ); if ( empty( $_POST['content'] ) ) exit( '-1<div id="message" class="error"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>' ); $activity_id = 0; if ( empty( $_POST['object'] ) && bp_is_active( 'activity' ) ) { $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) ); } elseif ( $_POST['object'] == 'groups' ) { if ( ! empty( $_POST['item_id'] ) && bp_is_active( 'groups' ) ) $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) ); } else { $activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] ); } if ($activity_id == "flood") { $bt_activity_throttle_time = bp_get_option ('bt_activity_time'); $bt_activity_message = bp_get_option( "bt_activity_message" ); $msg = ( $bt_activity_message ) ? $bt_activity_message : "You have to wait to post again"; exit( '-1<div id="message" class="error"><p>' . __( $msg, 'buddypress' ) . '</p></div>' ); } if ( empty( $activity_id ) ) exit( '-1<div id="message" class="error"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>' ); if ( bp_has_activities ( 'include=' . $activity_id ) ) { while ( bp_activities() ) { bp_the_activity(); locate_template( array( 'activity/entry.php' ), true ); } } exit; }4- The Buddypress Throttling Plugin Code
<?php add_action( 'admin_menu', 'plugin_menu' ); function plugin_menu() { // add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function); add_options_page( 'Buddypress Throttling | Settings', 'Buddypress Throttling', 'manage_options', 'buddypress_throttling', 'buddypress_throttling_options' ); } function buddypress_throttling_options() { //must check that the user has the required capability if (!current_user_can('manage_options')) { WP_die( __('You do not have sufficient permissions to access this page.') ); } // variables for the field and option names $hidden_field_name = 'submit_hidden'; // See if the user has posted us some information // If they did, this hidden field will be set to 'Y' if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) { // Activity $bp_activity_time_val = ( intval($_POST["bt_activity_time"]) <= 0 ) ? 0 : $_POST ["bt_activity_time"]; update_option( "bt_activity_time", $bp_activity_time_val ); $bp_activity_message_val = ( isset($_POST["bt_activity_message"]) && $_POST["bt_activity_message"] != "" ) ? $_POST["bt_activity_message"] : "Please wait before posting again"; update_option( "bt_activity_message", $bp_activity_message_val ); ?> <div class="updated"><p><strong><?php _e('Settings saved.', 'menu-test' ); ?></strong></p></div> <?php } // Activity read values $bt_activity_time = get_option( "bt_activity_time" ); $bt_activity_time = (intval($bt_activity_time) <= 0) ? 0 : $bt_activity_time; $bt_activity_message = get_option( "bt_activity_message" ); $bt_activity_message = ($bt_activity_message) ? $bt_activity_message : "Please wait before posting again"; echo '<div class="wrap">'; echo "<h2>" . __( 'Buddypress Throttling Settings', 'menu-test' ) . "</h2>"; ?> <form name="form1" method="post" action=""> <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y"> <div class="bt-plugin"> <style> .bt-plugin span { display: inline-block; width: 120px; margin-left: 20px } .bt-plugin textarea {width: 400px} </style> <h3><?php _e("On Activity Page: ", 'menu-test' ); ?></h3> <p><span>Throttling Time:</span><input type="text" name="bt_activity_time" value="<?php echo $bt_activity_time; ?>" size="20"> (in seconds)</p> <p><span>Message:</span><textarea name="bt_activity_message" rows="3"><?php echo $bt_activity_message; ?></textarea></p> </div> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> </p> </form> </div> <?php }Test it out locally, just replace the specified functions in these files with the functions I wrote, add the plugin code in a php file and save it under your Plugins directory (and activate it in the backend). The Plugin code will allow you to set the number of seconds for throttling as well as the message the user will see when he’s flooding.
Put this puzzle pieces together and you got Flooding control (for the activity page for now), which can easily be done for friend requests @bphelp).
June 6, 2013 at 11:29 am #165453In reply to: Action for Removing Member from group
ravibarnwal
Participantgroups_remove_member how to used in my plugin I am not able to used it.
Please explain .
I want to remove member from a group when new user registered.
I have received group_id and user_id from database. then I want to remove all member from that group without group admin.
I used function ‘groups_remove_member’ in my own plugin .
I am new in wordpress and buddypress coding.
My code is
if (!function_exists(‘auto_join’)) {
function update_auto_join_status($user_id) {
global $wpdb, $bp;// get list of groups to auto-join.
$group_list = $wpdb->get_results(“SELECT * FROM {$bp->groups->table_name} WHERE auto_join = 1″);foreach ($group_list as $group_auto_join) {
$members_count = groups_get_groupmeta( $group_auto_join->id, ‘total_member_count’ );
if($members_count < 5)
{
groups_accept_invite( $user_id, $group_auto_join->id );
}
else
{
group_auto_join_hidden_group($user_id, $group_auto_join->id);
}
}
$wpdb->query(“UPDATE {$wpdb->users} SET auto_join_complete = 1 WHERE ID = {$user_id}”);
}add_action( ‘user_register’, ‘auto_join’);
}function group_auto_join_hidden_group($user_id, $group_id)
{global $wpdb, $bp;
$utn = $wpdb->users; // Create a shortcut variable for wordpress users table.
$gmtn = $bp->groups->table_name . “_members”; // Create a shortcut variable for buddypress groups_members table.$mysql = “SELECT user_id FROM $gmtn WHERE group_id=$group_id”;
$results = $wpdb->get_results( $mysql);
foreach ( $results as $user) {
groups_remove_member($user->user_id, $group_id);}
}
my auto join working well but I am not able to remove member
Please help me what is wrong?April 17, 2013 at 3:59 pm #161953In reply to: sort group members by displayname in members.php?
JohnnyJonJon
ParticipantFYI, due to time constrains just had to edit source: line 1235 on /buddypress/bp-groups/bp-groups-classes.php – display_name ASC
$members = $wpdb->get_results( apply_filters( ‘bp_group_members_user_join_filter’, $wpdb->prepare( “SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY display_name ASC {$pag_sql}”, $group_id ) ) );
} else {
$members = $wpdb->get_results( apply_filters( ‘bp_group_members_user_join_filter’, $wpdb->prepare( “SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY display_name ASC {$pag_sql}”, $group_id ) ) );
}April 2, 2013 at 11:34 pm #159736In reply to: Create custom field in ’base’ group manually
webheadcoder
ParticipantThis code worked except my options weren’t ordered correctly. The option_order arg didn’t work. It looks like option_order does not get saved in the database. Instead I used the following code where it uses whatever order the country array is in:
`function your_plugin_activation() {
//country
wh_add_country_list();
}
//on activation or if you add this to functions use add_action ‘bp_init’
register_activation_hook(__FILE__, ‘your_plugin_activation’);function wh_add_country_list() {
if (xprofile_get_field_id_from_name(‘Country’)) return;add_filter(‘xprofile_field_options_before_save’, ‘wh_countries’);
add_filter(‘xprofile_field_default_before_save’, ‘wh_country_option_default’);
$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);
remove_filter(‘xprofile_field_options_before_save’, ‘wh_countries’);
remove_filter(‘xprofile_field_default_before_save’, ‘wh_country_option_default’);
}function wh_country_option_default() {
return array(‘US’ => 1);
}function wh_countries() {
return array(
‘US’ => ‘United States’
//list of other countries
);
}`March 21, 2013 at 3:53 pm #157397In reply to: Approve user to group hook with wp_email function ?
eberswine
Participant@shanebp Thanks for those hints!!
Wondering if I could pay you for this small “add_filter” ?
If so, let me know – I can pay PayPal instantly!
I would just need :
if ($group_id == 1) { email this to user accepted }
Thanks!!
February 14, 2013 at 11:01 am #153029Roger Coathup
ParticipantProblem is that groups_create_group() doesn’t set the total_member_count — so subsequent calls to set up the Groups Template fail to load the groups.
We worked around by explicitly setting: groups_update_groupmeta( $group_id, ‘total_member_count’, (int) groups_get_groupmeta( $group_id, ‘total_member_count’) + 1 );
Will add to trac as bug.
February 11, 2013 at 6:18 am #152808omgbud
ParticipantHi,
this is a code I use personally, but requires you to edit the bp-groups-actions.php, sorry i do not know how to write function.
open buddypress/bp-groups/bp-groups-actions.php
around line 150
After this line:
`do_action( ‘groups_group_create_complete’, $bp->groups->new_group_id );`Add this code:
` $to = “YOUREMAILADDRESS”;
$name= bp_core_get_username(bp_loggedin_user_id());
$groupname = bp_get_new_group_name(bp_get_new_group_id());
$groupurl = bp_get_group_permalink( $bp->groups->current_group );
$subject = “$name created new group $groupname”;
$body = “$name created new group $groupname, visit $groupurl”;
mail($to, $subject, $body);
`That’s it, when a user hit the Finish create group button this code will send to the email stated address with the newly created group link. use at your own risk. Hope someone better can create a theme function or a plugin for this.
This is needed to keep track of newly created groups to alert you if spammers are creating groups to spam.
Hope it helps.
February 2, 2013 at 8:24 pm #152239couchdavid
ParticipantI have also tried leaving the first lines in “edit.php” alone and adding to the bp_get_current_profile_group_id() function. I’m not nearly as smart as I thought I was. Ha!
function bp_current_profile_group_id() {
echo bp_get_current_profile_group_id();
}
function bp_get_current_profile_group_id() {if ( !$profile_group_id = bp_action_variable( 1 ) )
$profile_group_id = 1;{
elseif (custom_position (‘Actor’));
echo ‘Actor’;
$profile_group_id = 2;{
elseif ();
}
}return apply_filters( ‘bp_get_current_profile_group_id’, $profile_group_id ); // admin/profile/edit/[group-id]
}February 2, 2013 at 7:35 pm #152237couchdavid
ParticipantOkay, I feel like this one should work, but it’s showing not really making anything happen…
in my bp-custom file (lifted heavily from John James Jacoby’s informative post here: https://buddypress.org/support/topic/calling-specific-profile-fields-individually/#post-55905):
In my edit.php file, I replaced “bp_get_current_profile_group_id()” with the custom_position function
Thanks again!
February 2, 2013 at 7:02 pm #152236couchdavid
ParticipantPutting my IF statement into a function called “position_type”, I thought this could work, but still no dice:
if ( bp_has_profile( ‘profile_group_id=’ . bp_get_current_profile_group_id(position_type) ) ) :
while ( bp_profile_groups() ) : bp_the_profile_group();Thanks again, everyone.
February 2, 2013 at 2:16 pm #152227couchdavid
ParticipantI’m sure I need to change something in this line from the edit.php to get the desired effect:
But I can’t quite figure out what “bp_get_current_profile_group_id” function is *doing* in the xprofile template file. Or what I could do to it to make it behave the way I want it to without ruining its current function…
Any help is greatly appreciated as always.
January 12, 2013 at 2:03 pm #150420In reply to: members view in User Groups breaks
seogroup
ParticipantSorry for bumping but i really need help,
after hours of research i can not find a solution.Definitly, my: Group Members Loop doesn´t work. I have tried to replace him with the standard loop from the Documentation. But also this breaks.
I tried to get group id and do it on this way:
`$newgroupid = bp_get_group_id(); `
Id i get, but when i start members loop (with this id) nothing. Page breaks, means all scripts after this are stopped(Sidebar etc …).
Please HELP
January 10, 2013 at 8:55 pm #150188In reply to: [Resolved] Show Group Member List on Group Directory
shanebp
ModeratorUntested but try http://pastebin.com/BVTHyuEL
[
edit: too late, but same solution you came up with… congrats
It should work, from codex page, without the bp_get_group_id() call.
Made a note on that page.
]January 10, 2013 at 8:42 pm #150185In reply to: [Resolved] Show Group Member List on Group Directory
DKerrigan
ParticipantI figured it out!
Here is my new line 15 (php tags stripped out so you can see them here):
`if ( bp_group_has_members( ‘group_id=’.bp_get_group_id().’&exclude_admins_mods=false’ ) ) :`January 10, 2013 at 8:13 pm #150184In 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
-
AuthorSearch Results