Search Results for 'group_id'
-
AuthorSearch Results
-
February 15, 2017 at 1:40 am #263782
shanebp
Moderator>Am I on the right track?
This is wrong.
bp_get_group_id(get_current_user_id());
Look up that function to see how it is used.Ask LearnDash how to get the group id on the LearnDash screen that you want to use.
February 14, 2017 at 11:59 pm #263779Sergio Peña
ParticipantThank you for your response.
I did ask Learndash and they referred me to third party programmers.
Since I am using buddypress groups, I thought it was appropriate to ask here as well. Apologies if I was mistaken!
So would it be something like this:
add_shortcode('course_mentor','nex_course_mentor'); function nex_course_mentor($atts, $content = null){ if(!is_user_logged_in()) return; if(!bp_is_active('groups')) return; $nex_group_id = bp_get_group_id(get_current_user_id()); if(!empty($nex_group_id)){ foreach($nex_group_id as $nex_group_id){ $nex_admins = groups_get_group_admins( $nex_group_id ); foreach($admins as $admin){ ?> <a href="<?php echo bp_core_get_user_domain($admin->user_id) ?>" title="<?php echo bp_core_get_user_displayname( $admin->user_id, true ) ?>"> <?php echo bp_core_fetch_avatar ( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?></a>'; <?php } } } }I’m just copy/pasting and trying to connect a bunch of different answers together. As you can tell, I’m no coder.
Since each group may have more than one group leader/mentor I had a loop in there. Hopefully that will get the ball rolling on what I’m trying to do.
Am I on the right track?
February 14, 2017 at 11:45 pm #263778shanebp
ModeratorTry using
bp_get_group_id().
If you can get the group id, then usegroups_get_group_admins( $group_id )to get the group admins.
Pull out the user ids of the group admins and use the ids to get the user data that you want.NOTE: you should be asking LearnDash these questions.
By asking them here, you are asking volunteers to answer questions about a third-party premium plugin.
Therefore, you most likely won’t get much assistance here.February 8, 2017 at 4:53 pm #263617Topic: Self-inflicted BP Tables Madness
in forum How-to & Troubleshootingwarezit
ParticipantHello!
I am having an issue with BP, that I caused myself. I intentionally deactivated, then deleted, BP (on a 5 day old site) thinking that I wasn’t going to use it. Then I ran ‘WP Optimize’ which removed all the unused tables from the plugins I had installed, and removed unused transients, etc… This is what caused the problem.
Some time later, I went to re-install BP – which succeeds with no issues. Here’s where the issues crop up… Next, I went to create a new Group on the BP front-end, and it reports an error:
There was an error saving group details. Please try again.Enabling WP debug mode in “wp-config.php” reports this:
WordPress database error: [Table 'wordpress.wp_bp_groups' doesn't exist] SELECT id FROM wp_bp_groups WHERE slug = 'create' WordPress database error: [Table 'wordpress.wp_bp_activity' doesn't exist] SELECT id, user_id, date_recorded FROM wp_bp_activity WHERE component = 'members' AND type = 'last_activity' AND user_id IN (1) LIMIT 1 WordPress database error: [Table 'wordpress.wp_bp_activity' doesn't exist] SELECT id, user_id, date_recorded FROM wp_bp_activity WHERE component = 'members' AND type = 'last_activity' AND user_id IN (1) LIMIT 1 WordPress database error: [Table 'wordpress.wp_bp_activity' doesn't exist] SHOW FULL COLUMNS FROM <code>wp_bp_activity</code> WordPress database error: [Table 'wordpress.wp_bp_notifications' doesn't exist] SELECT * FROM wp_bp_notifications n WHERE user_id IN (1) AND component_name IN ('friends','messages','activity','groups','blogs') AND is_new = 1 WordPress database error: [Table 'wordpress.wp_bp_messages_recipients' doesn't exist] SELECT SUM(unread_count) FROM wp_bp_messages_recipients WHERE user_id = 1 AND is_deleted = 0 AND sender_only = 0 WordPress database error: [Table 'wordpress.wp_bp_friends' doesn't exist] SELECT id FROM wp_bp_friends WHERE (initiator_user_id = 1 OR friend_user_id = 1) ORDER BY date_created DESC WordPress database error: [Table 'wordpress.wp_bp_groups_members' doesn't exist] SELECT COUNT(DISTINCT m.group_id) FROM wp_bp_groups_members m, wp_bp_groups g WHERE m.group_id = g.id AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = 1 WordPress database error: [Table 'wordpress.wp_bp_messages_notices' doesn't exist] SELECT id FROM wp_bp_messages_notices WHERE is_active = 1I have been trying to find a solution for this online, for the last 4+ hours… and I have gotten nowhere… So, I am humbly asking for help here, on how to recreate these tables – WITHOUT DELETING AND RECREATING MY ENTIRE SITE. I have nearly 100 hours into this site so far, and I am NOT starting over. Starting over is NOT an option, so please save everyone’s time and skip suggesting this.
I have reviewed all of these links, and followed all of their respective directions, when applicable:
https://buddypress.org/support/topic/reinstall-should-i-delete-old-tables-from-db/
and, many many many many more links, that I am not going to go back and try to find…Any help with this would be great – I’d really like to use BP again… I have seen a number of other people online with this issue, so I know I am not the only one. There has to be some elegant solution to re-create the required SQL tables for the plugin, right?
I have tried running this, after I reinstalled BP the 4th time (with my TDL inserted, ofc):
https://xxxxxx.com/wp-content/plugins/buddypress/bp-core/bp-core-update.php?f=bp_update_to_2_7_4
But, it didn’t seem to do anything…Ubuntu 16.04.1
Apache 2.4.18
PHP 7.0.13
WP 4.7.2
BP 2.7.4
no other BP extension/plugins have been installed since the 1st time removing BPI am more than happy to provide any requested log files!
Thank you a TON in advance!! I look forward to getting this working again.
February 2, 2017 at 5:49 pm #263470In reply to: query error from bp_xprofile_field
danbp
ParticipantWhere did you find that code?
Have you tried to replace it by:
SELECT * FROM bp_xprofile_fields WHERE parent_id = 0 AND group_id > 1December 17, 2016 at 9:05 am #262209In reply to: Buddypress Cover Photo Does Not Save
danbp
Participantdid you respect the size instruction ? Sizes are theme dependant and vary from one install to another.
When it comes to image issues under BP, you’ll need to test your install without any plugin and only a Twenty theme active (never another one) as first and check if you can upload medias.
If OK, you activate BP and check again.You may also verify that the attachment folder exist and has eventually the correct write rights on the server:
wp-content/uploads/buddypress/members/USER_ID/cover-image/Similar path may exist for groups, which use/groups/GROUP_ID/instead of/members/USER_ID/If all is OK with Twenty, WP and BP, you can activate your plugins, one by one and testing after each. If still OK, you activate or install the definitive theme.
If things went wrong at this stage, you can be sure there is an issue with YOU or the theme.
You because you have omit a setting or did a wrong setting, or the theme, because all was ok while using a Twenty…
December 3, 2016 at 4:44 am #261654Kailan Wyatt
ParticipantI forgot to subscribe to the post via email. The code below will give you the group names instead of group ID.
Unfortunately, I am not sure how to sort by Groups at the moment. The reason is because Orders are a post type and doesn’t necessarily have a relation to BuddyPress groups. So there isn’t an immediate query I can think of to make this sortable. I hope that makes sense.
add_filter( 'manage_edit-shop_order_columns', 'MY_COLUMNS_FUNCTION' ); function MY_COLUMNS_FUNCTION( $columns ) { $new_columns = ( is_array( $columns ) ) ? $columns : array(); unset( $new_columns['order_actions'] ); //edit this for you column(s) //all of your columns will be added before the actions column $new_columns['MY_COLUMN_ID_1'] = 'סניף'; //stop editing $new_columns['order_actions'] = $columns['order_actions']; return $new_columns; } add_action( 'manage_shop_order_posts_custom_column', 'MY_COLUMNS_VALUES_FUNCTION', 2 ); function MY_COLUMNS_VALUES_FUNCTION( $column ) { global $post; // order id $order_id = $post->ID; // get Order object $order = new WC_Order( $order_id ); // get customer user id $user_id = $order->user_id; //start editing, I was saving my fields for the orders as custom post meta //if you did the same, follow this code if ( $column == 'MY_COLUMN_ID_1' && $user_id ) { // get user groups $groups = groups_get_user_groups( $user_id ); if ( ! empty( $groups ) && ! empty( $groups['groups'] ) ) { $group_list = array(); foreach ( $groups['groups'] as $key => $group_id ) { $group = groups_get_group( array( 'group_id' => $group_id ) ); $group_list[] = $group->name; } // let's make a comma separated list of the group IDs echo implode( ', ', $group_list ); //if you would like to get just one group ID, uncomment the following //echo $groups['groups'][0]; } } //stop editing } add_filter( "manage_edit-shop_order_sortable_columns", 'MY_COLUMNS_SORT_FUNCTION' ); function MY_COLUMNS_SORT_FUNCTION( $columns ) { $custom = array( //start editing 'MY_COLUMN_ID_1' => 'MY_COLUMN_1_POST_META_ID' //stop editing ); return wp_parse_args( $custom, $columns ); }December 2, 2016 at 8:33 pm #261646eavinu
ParticipantVery nice kailanw, thank you very much!
The column show an arrow for sorting but for some reason it doesn’t really sort, just mixes the order when I click on the column name, any idea why?
Another small thing, how would you go about showing the group name instead of ID?
I have this for showing the name on the users list page of admin:function cac_column_meta_value_group_name( $value, $object_id, $column ) { $custom_field_key = 'field_reg_groups'; if ( 'column-meta' == $column->get_type() && $custom_field_key == $column->get_field() && $value ) { // Value is a group ID here if( $group = groups_get_group( array( 'group_id' => $value ) ) ){ $value = $group->name; } } return $value; } add_filter( 'cac/column/meta/value', 'cac_column_meta_value_group_name', 10, 3 );Hope to be able to achieve the same for the orders page (you helped a lot!!!).
Is it possible to achieve a filter option for this field in the orders list?
December 2, 2016 at 3:22 pm #261632In reply to: [Resolved] get profile group name
kgrondell
ParticipantI figured it out.
$args = array( 'profile_group_id' => $current_profile_group_id ); $data_groups = BP_XProfile_Group::get( $args ); echo '<h1>'.$data_groups[0]->name.'</h1>'; echo '<p>'.'It looks like you have not given any responses here yet.'.'</p>';I added a counter var in the loop which initializes to 0 if after passing through the loop its 0 it will execute this.
November 18, 2016 at 8:17 pm #261164In reply to: Group header file problems
jaumearagay
ParticipantIn the group page you get this output:
int(91) string(21) "bp_groups_memberships" object(stdClass)#5452 (12) { ["id"]=> string(2) "91" ["group_id"]=> string(2) "13" ["user_id"]=> string(1) "6" ["inviter_id"]=> string(1) "0" ["is_admin"]=> string(1) "0" ["is_mod"]=> string(1) "0" ["user_title"]=> string(0) "" ["date_modified"]=> string(19) "2016-09-15 11:37:10" ["comments"]=> string(0) "" ["is_confirmed"]=> string(1) "0" ["is_banned"]=> string(1) "0" ["invite_sent"]=> string(1) "0" } int(91) string(21) "bp_groups_memberships" object(stdClass)#5465 (12) { ["id"]=> string(2) "91" ["group_id"]=> string(2) "13" ["user_id"]=> string(1) "6" ["inviter_id"]=> string(1) "0" ["is_admin"]=> string(1) "0" ["is_mod"]=> string(1) "0" ["user_title"]=> string(0) "" ["date_modified"]=> string(19) "2016-09-15 11:37:10" ["comments"]=> string(0) "" ["is_confirmed"]=> string(1) "0" ["is_banned"]=> string(1) "0" ["invite_sent"]=> string(1) "0" } int(91) string(21) "bp_groups_memberships" object(stdClass)#5465 (12) { ["id"]=> string(2) "91" ["group_id"]=> string(2) "13" ["user_id"]=> string(1) "6" ["inviter_id"]=> string(1) "0" ["is_admin"]=> string(1) "0" ["is_mod"]=> string(1) "0" ["user_title"]=> string(0) "" ["date_modified"]=> string(19) "2016-09-15 11:37:10" ["comments"]=> string(0) "" ["is_confirmed"]=> string(1) "0" ["is_banned"]=> string(1) "0" ["invite_sent"]=> string(1) "0" } int(91) string(21) "bp_groups_memberships" object(stdClass)#5465 (12) { ["id"]=> string(2) "91" ["group_id"]=> string(2) "13" ["user_id"]=> string(1) "6" ["inviter_id"]=> string(1) "0" ["is_admin"]=> string(1) "0" ["is_mod"]=> string(1) "0" ["user_title"]=> string(0) "" ["date_modified"]=> string(19) "2016-09-15 11:37:10" ["comments"]=> string(0) "" ["is_confirmed"]=> string(1) "0" ["is_banned"]=> string(1) "0" ["invite_sent"]=> string(1) "0" } int(91) string(21) "bp_groups_memberships" object(stdClass)#5751 (12) { ["id"]=> string(2) "91" ["group_id"]=> string(2) "13" ["user_id"]=> string(1) "6" ["inviter_id"]=> string(1) "0" ["is_admin"]=> string(1) "0" ["is_mod"]=> string(1) "0" ["user_title"]=> string(0) "" ["date_modified"]=> string(19) "2016-09-15 11:37:10" ["comments"]=> string(0) "" ["is_confirmed"]=> string(1) "0" ["is_banned"]=> string(1) "0" ["invite_sent"]=> string(1) "0" } int(91) string(21) "bp_groups_memberships" object(stdClass)#5753 (12) { ["id"]=> string(2) "91" ["group_id"]=> string(2) "13" ["user_id"]=> string(1) "6" ["inviter_id"]=> string(1) "0" ["is_admin"]=> string(1) "0" ["is_mod"]=> string(1) "0" ["user_title"]=> string(0) "" ["date_modified"]=> string(19) "2016-09-15 11:37:10" ["comments"]=> string(0) "" ["is_confirmed"]=> string(1) "0" ["is_banned"]=> string(1) "0" ["invite_sent"]=> string(1) "0" } int(91) string(21) "bp_groups_memberships" object(stdClass)#5753 (12) { ["id"]=> string(2) "91" ["group_id"]=> string(2) "13" ["user_id"]=> string(1) "6" ["inviter_id"]=> string(1) "0" ["is_admin"]=> string(1) "0" ["is_mod"]=> string(1) "0" ["user_title"]=> string(0) "" ["date_modified"]=> string(19) "2016-09-15 11:37:10" ["comments"]=> string(0) "" ["is_confirmed"]=> string(1) "0" ["is_banned"]=> string(1) "0" ["invite_sent"]=> string(1) "0" } int(6) string(22) "bp_friends_friendships" object(stdClass)#5774 (6) { ["id"]=> string(1) "6" ["initiator_user_id"]=> string(1) "6" ["friend_user_id"]=> string(2) "36" ["is_confirmed"]=> string(1) "1" ["is_limited"]=> string(1) "0" ["date_created"]=> string(19) "2016-09-06 09:22:58" } int(1) string(22) "bp_friends_friendships" object(stdClass)#5775 (6) { ["id"]=> string(1) "1" ["initiator_user_id"]=> string(1) "6" ["friend_user_id"]=> string(1) "5" ["is_confirmed"]=> string(1) "1" ["is_limited"]=> string(1) "0" ["date_created"]=> string(19) "2016-08-22 10:25:37" } int(6) string(16) "bp_last_activity" array(3) { ["user_id"]=> string(1) "6" ["date_recorded"]=> string(19) "2016-11-18 20:15:56" ["activity_id"]=> string(1) "1" }November 18, 2016 at 2:43 pm #261154In reply to: Group header file problems
jaumearagay
ParticipantThe code:
Administradores de grupo $uncached group_ids: array(0) { } $group_mods before foreach: bool(false) $group_mods after foreach: array(1) { [0]=> object(stdClass)#5830 (1) { ["user_id"]=> int(0) } } Foto del perfil de Matilde Rodríguez-Castellano $uncached group_ids: array(0) { } $group_mods before foreach: bool(false) $group_mods after foreach: array(1) { [0]=> object(stdClass)#5876 (1) { ["user_id"]=> int(0) } } Moderadores del Grupo Sin modsThe screen capture: http://imgur.com/a/0H10D
November 15, 2016 at 10:08 am #261018In reply to: Group header file problems
jaumearagay
ParticipantI have:
a.- Updated to BP 2.7.2. <– Still same problems but warnings hidden by my code.
b.- Removed the buddypress folder in my theme with edited files and checked. <– Still same problems: Warnings (as my code did not hide them), “Moderators” tag and “no mods” string.
c.- Downloaded and activated Twenty Sixteen theme. <– Same as in previous step.
And I get the same warning explained in the first entry in this post so it’s not about my modified files and it’s not about a theme problem.
There are still two problems:
1.- The warning points to get_group_moderator_ids( $group_id ) in /wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-member.php
I don’t have (or have had) moderators in any group so, “Creating default object from empty value” <– What default object from what empty value?
2.- The problem is somewhere else: In line 33 of the group-header.php file (in groups/single/ ) we find this line:
if ( bp_group_has_moderators() ) :where “bp_group_has_moderators()” is giving a false “true” value as I don’t have moderators in any group so it should not execute in the first place. And after the Moderators tag it says “no mods”, so it on a later step recognizes there are no moderators!!!
Has the bp_group_has_moderators() function or get_group_moderator_ids( $group_id ) function been altered? Or the data about mods and/or admins in the groups?
Because one of them creates two warnings (one before listing the admins and one before listing the mods) that were not there before and also shows a “Moderators” tag that did not appear as the
if ( bp_group_has_moderators() )returned the FALSE value my no-mods groups “deserve” (which it later recognizes when adding the “no mods” string) that now returns this “buggy” TRUE value and shows the tag.November 3, 2016 at 8:47 pm #260691In reply to: CAN BE DELETED
jayront
ParticipantHi thanks for the reply. I tried that and when i clicked on a profile (without it loading to go to the button) it was already adding 4000+ new entries in my DB with the same group_id and user_id.
October 5, 2016 at 2:10 pm #259421danbp
ParticipantYou need to specify the object.
$attachment = bp_attachments_get_attachment( 'url', array( 'object_dir' => 'groups', 'item_id' => $group_id, ) );Reference
October 5, 2016 at 1:21 pm #259419m1000
ParticipantI just what to use it inside img tag.
BTW, why this code doesn’t work for groups?
function bp_cover_group_img_path() { // Is the current page a user page? if ( bp_is_group() ) { $group_id = bp_get_group_id(); $attachment = bp_attachments_get_attachment( 'url', array( 'item_id' => $group_id ) ); $image_path = $attachment; // output only if an attachment exist if( !empty( $attachment ) ): echo $image_path; endif; } } add_action( 'bp_group_cover_path', 'bp_cover_group_img_path' );August 27, 2016 at 6:43 pm #258125In reply to: tinymce in activity replies and comments
danbp
ParticipantThe ultimate tutorial to add wp_editor to What’s New textarea (on Site, Members and Group Activities pages).
Warning
The What’s New feature was never intended to publish posts or formatted text. It was imagined for brief announcement or instant conversation. That’s why this textarea is texturized and doesn’t allow much HTML tags. It is also ajaxified and need the original BP ID to work.
You will use it at your own risk.The following trick will let you remove the existing textarea from the template and replace it with a custom wp_editor. And it will be very customized ! For example, you will not have the visual tab, but only his HTML version, similar to the one you see on this forum for example.
Required:
BuddyPress activated
a working child theme
some understanding of HTML and php grammarThis trick was succesfully tested on a single install with WP 4.6, BP 2.6.2 and a Twenty Sixteen child theme.
Start !
Read from here how to remove the textarea in post-form.phpThe code to remove is line 40 and looks like this:
<textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10" <?php if ( bp_is_group() ) : ?>data-suggestions-group-id="<?php echo esc_attr( (int) bp_get_current_group_id() ); ?>" <?php endif; ?> ><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_textarea( $_GET['r'] ); ?> <?php endif; ?></textarea>You replace it by:
<?php $content = ''; $editor_id = 'whats-new'; wp_editor( $content, $editor_id ); ?>As the visual edit tab doesn’t work, you must deactivate it. In your child-theme functions.php, add this:
add_filter( 'user_can_richedit' , '__return_false', 50 );And that’s it !
If you want also rich edit for activity comments, which i didn’t recommand for sites who have many comments, you can use the same technique as above, with some more settings. Note that each comment has is own ID and that each comment editor should also have an unique ID.
First, you need to remove the textarea from (child-theme/buddypress/)activity/entry.php
You remove this:
<textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input bp-suggestions" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
and replace it by<?php $id = bp_get_activity_id(); $content = ''; $editor_id = 'ac-input-'. $id; $settings = array( 'textarea_name' => 'ac_input_'. $id, 'editor_class' => 'ac-input bp-suggestions' ); wp_editor( $content, $editor_id, $settings ); ?>With Twenty Sixteen, i first couldn’t see the Post Update button and the option selector. I got it with this little CSS adjustment (in child-theme/style.css).
div#whats-new-options { display: block!important;}Function reference: wp_editor.
August 1, 2016 at 3:04 am #257144In reply to: how to add new members to groups automatically?
buddycore
ParticipantFirst you are creating a custom function called
automatic_group_membership()this takes one parameter$user_id.This function terminates if there is no
$user_idprovided, meaning you don’t run rogue code and your site is more optimised.When a
$user_idis present thegroups_accept_invite()function is run. This function is a BuddyPress core function you can find it inwp-content/plugins/buddypress/bp-groups/bp-groups-functions.phpon line 1400.It accepts two parameters a
$user_idand a$group_id. You need both in order to create the relationship.This function is “hooked” with
add_action()which is a WordPress core function. This functionadd_action()has many hooks available for various situations. You can read more about hooks here https://codex.wordpress.org/Plugin_API/Hooks.Essentially it’s an opportunity to run your own code against WordPress core, or in this case BuddyPress core. BuddyPress provides the hook and we use them to achieve cool things.
So the hook in this case is
bp_core_activated_userand the code we want to run when this hook is available would be the customer functionautomatic_group_membershipwhich is passed as a second parameter.I’m not sure where the
$user_idgets populated along the way here, nor the$group_idmaybe someone can help?Otherwise, I would do this not on activation but when a user has logged in for the first time.
Then we have access to
global $bpwhich contains aloggedin_user->idwhich can be used with this function and you could manually set the$group_idin bp-custom.phpAugust 1, 2016 at 12:45 am #257139In reply to: how to add new members to groups automatically?
peterBerlin
ParticipantHi,
For a newbie like me, could I kindly ask to see how the code:
function automatic_group_membership( $user_id ) {
if( !$user_id ) return false;groups_accept_invite( $user_id, $group_id );
}
add_action( ‘bp_core_activated_user’, ‘automatic_group_membership’ );As its supposed to look so its ready for use in bp-custom.php
Kind regards and have a nice Sunday.
July 20, 2016 at 10:35 pm #256859In reply to: Struggling with Group Invites
buddycore
Participantmy-theme/buddypress/groups/create.php
<?php if(bp_is_group_creation_step('group-invites')) : ?> <?php do_action('bp_before_group_invites_creation_step'); ?> <?php if(bp_is_active('friends') && bp_get_total_friend_count(bp_loggedin_user_id())) : ?> <div class="left-menu"> <div id="invite-list"> <ul> <?php bp_new_group_invite_friend_list(); ?> </ul> <?php wp_nonce_field('groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user'); ?> </div> </div><!-- LEFT --> <div class="main-column"> <div id="message" class="info"> <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p> </div> <ul id="friend-list" class="item-list"> <?php if(bp_group_has_invites()) : ?> <?php while(bp_group_invites()) : bp_group_the_invite(); ?> <li id="<?php bp_group_invite_item_id(); ?>"> <?php bp_group_invite_user_avatar(); ?> <h4><?php bp_group_invite_user_link(); ?></h4> <span class="activity"><?php bp_group_invite_user_last_active(); ?></span> <div class="action"> <a class="remove" href="<?php bp_group_invite_user_remove_invite_url(); ?>" id="<?php bp_group_invite_item_id(); ?>"><?php _e('Remove Invite', 'buddypress'); ?></a> </div> </li> <?php endwhile; ?> <?php wp_nonce_field('groups_send_invites', '_wpnonce_send_invites'); ?> <?php endif; ?> </ul> </div><!-- MAIN --> <?php else : ?> <div id="message" class="info"> <p><?php _e('Once you have built up friend connections you will be able to invite others to your group.', 'buddypress'); ?></p> </div> <?php endif; ?> <?php wp_nonce_field('groups_create_save_group-invites'); ?> <?php do_action('bp_after_group_invites_creation_step'); ?> <?php endif; ?>my-theme/buddypress/groups/single/send-invites.php
<?php /** * BuddyPress - Groups Send Invites * * @package BuddyPress * @subpackage bp-legacy */ /** * Fires before the send invites content. * * @since 1.1.0 */ do_action( 'bp_before_group_send_invites_content' ); ?> <?php /* Does the user have friends that could be invited to the group? */ if ( bp_get_new_group_invite_friend_list() ) : ?> <?php /* 'send-invite-form' is important for AJAX support */ ?> <form action="<?php bp_group_send_invite_form_action(); ?>" method="post" id="send-invite-form" class="standard-form"> <div class="invite"> <?php bp_get_template_part( 'groups/single/invites-loop' ); ?> </div> <div class="submit"> <input type="submit" name="submit" id="submit" value="<?php esc_attr_e( 'Send Invites', 'buddypress' ); ?>" /> </div> <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ); ?> <?php /* This is important, don't forget it */ ?> <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id(); ?>" /> </form><!-- #send-invite-form --> <?php /* No eligible friends? Maybe the user doesn't have any friends yet. */ elseif ( 0 == bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?> <div id="message" class="info"> <p class="notice"><?php _e( 'Group invitations can only be extended to friends.', 'buddypress' ); ?></p> <p class="message-body"><?php _e( "Once you've made some friendships, you'll be able to invite those members to this group.", 'buddypress' ); ?></p> </div> <?php /* The user does have friends, but none are eligible to be invited to this group. */ else : ?> <div id="message" class="info"> <p class="notice"><?php _e( 'All of your friends already belong to this group.', 'buddypress' ); ?></p> </div> <?php endif; ?> <?php /** * Fires after the send invites content. * * @since 1.2.0 */ do_action( 'bp_after_group_send_invites_content' ); ?>July 9, 2016 at 8:47 pm #256396In reply to: how to add new members to groups automatically?
Earl_D
Participant@5high I have come across that code but didn’t know if it would be appropriate since I am not using s2 membership plugin.
one quick question. Where do you put the group you want joined. Is it as simple as replacing the $group_id string with the group id number?Thanks for the feedback and assistance.
July 9, 2016 at 1:39 pm #256168In reply to: How do I change the activity-greeting copy?
socialc
Participant@danbp yeah, sorry about that :). Reason I went a bit further was when working on a theme earlier I was using a function
get_displayed_group_id()or something with a similar name. I was expecting a return value but it was echoing no matter where I placed this.Ended up using a different method.
Just wondered if there were other functions inside BuddyPress that looked like a return value but had output instead.
July 1, 2016 at 7:19 pm #255640In reply to: Link to User’s Group’s Forums
David Cavins
KeymasterMenus aren’t very php-friendly, usually, but you could do something like this:
<?php if ( groups_is_user_member( bp_loggedin_user_id(), $group_id_of_group_A ) ) { $group = groups_get_group( array( 'group_id' => $group_id_of_group_A ) ); ?> <li><a href="<?php echo bp_get_group_permalink( $group ) . 'forum/'; ?>"><?php bp_group_name( $group ) ?> Forum</a></li> <?php }You may have to hook onto
wp_nav_menu_itemsor similar to inject the link. It depends on your theme. That would look like:add_filter( 'wp_nav_menu_items', 'my_inject_group_forum_link_into_menu' ); my_inject_group_forum_link_into_menu( $items ) { if ( groups_is_user_member( bp_loggedin_user_id(), $group_id_of_group_A ) ) { $group = groups_get_group( array( 'group_id' => $group_id_of_group_A ) ); $items .= '<li><a href="' . bp_get_group_permalink( $group ) . 'forum/">' . bp_get_group_name( $group ) . 'Forum</a></li>'; <?php } return $items; }June 29, 2016 at 4:26 am #255460In reply to: Fatal error on a BuddyPress 2.6.0 upgrade
Rintu Thomas
ParticipantHi,
I have the same problem like “Fatal error: Call to undefined function bp_get_current_group_id() in /home/…/public_html/…/wp-content/plugins/buddypress/bp-groups/classes/class-bp-group-extension.php on line 484”. The solution given above can fixed the issue, but it is affecting when i am updating the plugin. So, how can i override this file inside the theme so that the change wont lose when i update the plugin buddypress.June 28, 2016 at 4:08 am #255368metaverso
Participantmy fix:
Fatal error: Call to undefined function bp_get_current_group_id() in /wp-content/plugins/buddypress/bp-groups/classes/class-bp-group-extension.php on line 488[ soluction ]
public static function get_group_id() { if ( defined( 'WP_NETWORK_ADMIN' ) && bp_is_active('groups')) { // -----------fix add line 1 echo get_called_class();// -----------fix add line 2 // Usually this will work. $group_id = bp_get_current_group_id(); // On the admin, get the group id out of the $_GET params. if ( empty( $group_id ) && is_admin() && ( isset( $_GET['page'] ) && ( 'bp-groups' === $_GET['page'] ) ) && ! empty( $_GET['gid'] ) ) { $group_id = (int) $_GET['gid']; } // This fallback will only be hit when the create step is very // early. if ( empty( $group_id ) && bp_get_new_group_id() ) { $group_id = bp_get_new_group_id(); } // On some setups, the group id has to be fetched out of the // $_POST array // @todo Figure out why this is happening during group creation. if ( empty( $group_id ) && isset( $_POST['group_id'] ) ) { $group_id = (int) $_POST['group_id']; } return $group_id; }// -----------fix add line 3 }June 27, 2016 at 5:05 pm #255336In reply to: bp_activity_filter_kses function
danbp
Participantcolor buttons are TinyMCE tools and not html tags. The only way to get them would be to use the editor toolbar.
Here a scenario you could use:
– create a child-theme and add post-form.php to it (copy from bp-templates/bp-legacy/buddyPress/activity/post-form.php).
Result:your-child-theme/buddypress/activity/post-form.phpIn that file, go to line:40 where textarea start.
Inser this action hook:<?php if ( bp_is_groups_component() ) : ?> <?php do_action( 'blablabla' ); ?> <?php endif ?>Then add this
<?php if ( ! bp_is_groups_component() ) : ?>
<textarea class="bp-suggestions"......bla...bla...</textarea>
and add <?php endif ?> after the textarea closing tag.This contionnals will show a custom area for the desired group and prevent update area to appear on all other groups home pages.
So if a user is member of different groups, he will get a texteditor for group_id 13 and the normal update area on all others.
The custom template is ready. Now the fonctions we need.
Open bp-custom.php (or create it) and paste in those snippets.
Adding the texteditor:
function bpfr_whats_new_tiny_editor() { // deactivation of the visual tab, so user can't play with style tools //add_filter ( 'user_can_richedit' , create_function ( '$a' , 'return false;' ) , 50 ); $content = ""; // building the what's new textarea if ( isset( $_GET['r'] ) ) : $content = esc_textarea( $_GET['r'] ); endif; // adding tinymce tools $editor_id = 'whats-new'; $settings = array( 'textarea_name' => 'whats-new', 'teeny' => false, 'media_buttons' => true, 'drag_drop_upload' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' )); // get the editor wp_editor( $content, $editor_id, $settings ); } add_action( 'whats_new_textarea', 'bpfr_whats_new_tiny_editor' );A simple function who add the original textarea for users who are group members, but not allowed to rich edit.
function my_textarea() { ?> <textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10" <?php if ( bp_is_group() ) : ?>data-suggestions-group-id="<?php echo esc_attr( (int) bp_get_current_group_id() ); ?>" <?php endif; ?> ><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_textarea( $_GET['r'] ); ?> <?php endif; ?></textarea> <?php }And the last one, where you set up the group allowed to publish updates using edit tools.
function trotro() { if ( bp_is_groups_component() ) : $check = groups_is_user_member( bp_loggedin_user_id(), bp_get_group_id() ); $check_group = bp_get_group_id(); if ($check != 0 && $check_group == 21 && 'leon' == bp_current_item() ){ echo 'Wow! You can rich edit in this group.'; bpfr_whats_new_tiny_editor(); } else { echo 'Sorry, you cannot rich edit in this group'; my_textarea(); } endif; } add_action( 'blablabla', 'trotro' );Now, any member which is part of the group leon, group id 23 can publish updates and use the color picker and all other things which are on the edit bar.
Only thing you have to do is to adjust leon and id to your rules.
Successfully tested on 2.6 and 2016.
May this help you to go further with your BuddyPress project. 🙂
-
AuthorSearch Results