Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'group_id'

Viewing 25 results - 501 through 525 (of 564 total)
  • Author
    Search Results
  • #71064
    rich! @ etiviti
    Participant

    First, I just found a small bug and fixed it in the trunk – you just need to update the file: bp-forum-extras-activity.php

    Second, make sure you add the theme edit (detailed on forum extras wp-admin page)

    The comments appear directly underneath the post which has the activity. It pulls in all replies for the given post (so threaded). It will work for any backdated activity comments – whatever it can find for the given group_id and post_id (item_id)

    http://files.etiviti.com/misc/buddypress/bp-group-forum-topic-post-activity-1.gif

    http://files.etiviti.com/misc/buddypress/bp-group-forum-topic-post-activity-2.gif

    http://files.etiviti.com/misc/buddypress/bp-group-forum-topic-post-activity-3.gif

    http://files.etiviti.com/misc/buddypress/bp-group-forum-topic-post-activity-4.gif

    #70339
    Andy Peatling
    Keymaster

    $activity_id = bp_activity_post_update( array( ‘content’ => $content, ‘user_id’ => $user_id ) );

    $activity_id = groups_post_update( array( ‘content’ => $content, ‘user_id’ => $user_id, ‘group_id’ => $group_id ) );

    The functions above will post an update by the user on their profile, or in a group. It will return the activity ID which you can use to attach a comment:

    $comment_id = bp_activity_new_comment( array( ‘activity_id’ => $activity_id, ‘content’ => $content, ‘user_id’ => $user_id, ‘parent_id’ => [optional] ) );

    You could post a reply to that comment by using the same function and passing the $comment_id as the parent_id param.

    #69371

    In reply to: bbpress and buddypress

    r-a-y
    Keymaster

    You could create one group that all people join when they register.

    Use DJPaul’s Welcome Pack plugin for that:

    https://wordpress.org/extend/plugins/welcome-pack/

    Otherwise go the external bbPress route, and yes, you’ll need to theme it.

    [EDIT]

    Forgot that Paul changed his plugin so it sends out group invites, instead of auto joining groups.

    If you want to make Paul’s plugin automatically join groups.

    Change the following lines in the Welcome Pack plugin from:

    groups_invite_user( array( 'user_id' => $new_user_id, 'group_id' => $group_id, 'inviter_id' => $group->creator_id ) );
    groups_send_invites( $group->creator_id, $group_id );

    to:

    groups_join_group( $group_id, $new_user_id );

    I should say I haven’t tried this, but it should work.

    #68827
    Anointed
    Participant

    going through cleaning up my server logs and noticed the following:

    Notice: Undefined offset: 0 in /wp-content/plugins/bp-groupblog/bp-groupblog.php on line 355
    Notice: Undefined index: default-administrator in /wp-content/plugins/bp-groupblog/bp-groupblog.php on line 361
    Notice: Undefined index: default-moderator in /wp-content/plugins/bp-groupblog/bp-groupblog.php on line 362
    Notice: Undefined index: default-member in /wp-content/plugins/bp-groupblog/bp-groupblog.php on line 363
    Notice: Undefined index: group_id in /wp-content/plugins/bp-groupblog/bp-groupblog.php on line 364
    Notice: Undefined index: groupblog-silent-add in /wp-content/plugins/bp-groupblog/bp-groupblog.php on line 365

    also, very strange problem that just popped up. I did disable every plugin to make sure it was not the issue, but did not help. I tried it on the default bp template, as well as my own.

    http://jerrygaffney.net/groups/mens-ministries/blog/

    notice that there is no title to the article nor is there anything in the ‘page’ icon.

    I think ‘the_title’ is not passing through properly but it does pass through on the blog activity below the blog page.. very very strange, as it used to work, and nothing changed that I know of….

    #68596

    In reply to: @ Group

    rich! @ etiviti
    Participant

    a simple example that will auto link a group slug mention in an activity update

    this a proof == i’m lazy. so it only matches the group slug and NOT the true name (someone would have to build a function for that)

    …and this uses a caret but anything can be used

    function bp_activity_at_groupname_filter( $content ) {

    //define your catch hook, i'm partial to the bang but lets eat a caret
    $pattern = '/[\\^]+([A-Za-z0-9-_]+)/';
    preg_match_all( $pattern, $content, $groupnames );

    /* Make sure there's only one instance of each groupname */
    if ( !$groupnames = array_unique( $groupnames[1] ) )
    return $content;

    foreach( (array)$groupnames as $groupname ) {

    //note this is the group slug as for a proof - need to build a group "name" lookup function
    if ( !$group_id = BP_Groups_Group::group_exists( $groupname ) )
    continue;

    //too much work to get a link
    $thisgroup = new BP_Groups_Group( $group_id );

    $content = str_replace( "^$groupname", "<a href='" . bp_get_group_permalink( $thisgroup ) . "' rel='nofollow'>^$groupname</a>", $content );
    }

    return $content;
    }
    add_filter( 'bp_activity_new_update_content', 'bp_activity_at_groupname_filter' );
    add_filter( 'groups_activity_new_update_content', 'bp_activity_at_groupname_filter' );
    add_filter( 'pre_comment_content', 'bp_activity_at_groupname_filter' );
    add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_groupname_filter' );
    add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_groupname_filter' );
    add_filter( 'bp_activity_comment_content', 'bp_activity_at_groupname_filter' );

    #68544
    Nick Watson
    Participant
    function bp_featured_group_form() {
    if ( is_site_admin ) {
    ?>
    <hr />
    <div class="radio">
    <label><input type="radio" name="bp_featured_group" value="normal" <?php bp_featured_group_setting('normal') ?> /> <?php _e( 'This is just a normal group', 'featured_group' ) ?></label>
    <label><input type="radio" name="bp_featured_group" value="Featured" <?php bp_featured_group_setting('Featured') ?> /> <?php _e( 'This is a featured group', 'featured_group' ) ?></label>
    </div>
    <hr />
    <?php
    }
    }
    add_action ( 'bp_after_group_settings_admin' ,'bp_featured_group_form' );
    add_action ( 'bp_after_group_settings_creation_step' ,'bp_featured_group_form' );

    function bp_featured_group() {
    if (bp_get_featured_group()) {
    echo bp_get_featured_group();
    }
    }

    // Get the official title group setting
    function bp_get_featured_group( $group = false ) {
    global $groups_template;
    if ( !$group )
    $group =& $groups_template->group;
    $featured_group = groups_get_groupmeta( $group->id, 'bp_featured_group' );
    return apply_filters( 'bp_featured_group', $featured_group );
    }

    // echo official title group checked setting for the group admin - default to 'normal' in group creation
    function bp_featured_group_setting( $setting ) {
    if ( $setting == bp_get_featured_group() )
    echo ' checked="checked"';
    if ( !bp_get_featured_group() && $setting == 'normal' )
    echo ' checked="checked"';
    }

    // Save the official_title group setting in the group meta, if normal, delete it
    function bp_save_featured_group( $group_id ) {
    global $bp, $_POST;
    if ( $postval = $_POST['bp_featured_group'] ) {
    if ( $postval == 'Featured' )
    groups_update_groupmeta( $group_id->id, 'bp_featured_group', $postval );
    elseif ( $postval=='normal' )
    groups_delete_groupmeta( $group_id->id, 'bp_featured_group' );
    }
    }
    add_action( 'groups_group_after_save', 'bp_save_featured_group' );

    I may as well post the code,

    Here it is.

    Thanks

    #67609
    Peter Anselmo
    Participant

    Ray,

    Thanks for the replies. I was using the full wp-content/blog.dir/group_id path as that’s what avatars and several other components use. Which brings me to your next question – files outside of group documents. Yes, they’re working, even with a very similar path.

    Check out the avatar for this group (The dog photo):

    http://wpmu.sixtysixinc.com/wpmu2.8.6/groups/my-group/documents/

    It has the exact same url structure as the documents:

    http://wpmu.sixtysixinc.com/wpmu2.8.6/wp-content/blogs.dir/1/files/group-avatars/3/0fde224e7a1e14965943249bc7fa519b-bpthumb.jpg

    Yet, it’s not getting redirected, and it works fine.

    #67195
    Andy Peatling
    Keymaster

    Great plugin Boone! I found one issue though –

    There’s no pagination, so I could only see the first page of groups. You can just add this:

    <div class="tablenav">
    <div class="tablenav-pages">

    <span class="displaying-num" id="group-dir-count">
    <?php bp_groups_pagination_count() ?>
    </span>

    <span class="page-numbers" id="group-dir-pag">
    <?php bp_groups_pagination_links() ?>
    </span>

    </div>
    </div>

    You will need to move the <?php if( bp_has_groups( $args ) ) : ?> above that though and get it outside of the table generation.

    I also thought it would be nice to add a column at the start for the group avatar?

    <td scope="row" style="text-align: center; padding: 5px 10px">
    <a href="admin.php?page=bp-group-management/bp-group-management-bp-functions.php&action=edit&id=<?php bp_group_id() ?>" class="edit"><?php bp_group_avatar( 'width=35&height=35' ); ?></a>
    </td>

    You’d probably want to move the inline CSS out of there.

    rich! @ etiviti
    Participant

    edit the theme file /activity/entry.php and under the activity-meta div – you’ll see the link for comments. you could add the following checks to that section:

    bp_get_activity_object_name() == 'groups'  //the component name
    groups_is_user_member( $bp->loggedin_user->id, bp_get_activity_item_id() ) //if a group then item_id references the group_id

    (i didn’t test this – just what i found)

    #66437
    draganbabic
    Member

    Hi guys,

    thanks for the ideas. So far I got this running:

    <?php if ( bp_has_profile('profile_group_id=2') ) : ?>

    <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    <?php if ( bp_profile_group_has_fields() ) : ?>

    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>

    <?php if ( bp_field_has_data() ) : ?>

    style="<?php bp_the_profile_field_value() ?>"

    <?php endif; ?>

    <?php endwhile; ?>

    <?php endif; ?>

    <?php endwhile; ?>

    <?php else: ?>

    <?php endif;?>

    And this indeed outputs the desired value, but it is also wrapped in a paragraph and autolinked. Please do note that I have no idea what I am doing here, weather it is valid, good or anything else, this just got the job done, so it’s a starting point.

    I have searched the forum and found this code that is supposed to remove the autolinking:

    <?php

    function remove_links(){

    remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 2 );

    }

    add_action( 'plugins_loaded', 'remove_links' );

    ?>

    However it doesn’t do that once placed in bp-custom.php

    Any pointers?

    #66108
    rich! @ etiviti
    Participant

    i notified Andy of this problem, but here is my fix – needs to hash the post link (but this would leave to problems when removing a feed and the activity not deleting)

    /* Fetch an existing activity_id if one exists. */
    if ( function_exists( 'bp_activity_get_activity_id' ) )
    $id = bp_activity_get_activity_id( array( 'user_id' => false, 'component' => $bp->groups->id, 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash( $post['link'] ) ) );

    /* Record or update in activity streams. */
    groups_record_activity( array(
    'id' => $id,
    'user_id' => false,
    'action' => $activity_action,
    'content' => $activity_content,
    'primary_link' => $post['link'],
    'type' => 'exb',
    'item_id' => $group_id,
    'secondary_item_id' => wp_hash( $post['link'] ),
    'recorded_time' => gmdate( "Y-m-d H:i:s", $post_date ),
    'hide_sitewide' => $hide_sitewide
    ) );

    #64299
    neobabs
    Participant

    @peter-anselmo

    is it not cause of this in line 106 in classes.php ? :

    ” $this->user_id,

    $this->group_id,

    time(),

    time(),

    $this->file,

    $this->name,

    $this->description

    #62814
    sweller
    Participant

    I’d like to open this one back up. The project is for a local recycling program and I’m having trouble with a form for members to schedule pickups on the profile/index page. It calls XProfile address fields and tomorrow’s date for the default values, and should insert them into a custom table. The plugin creates a table and pulls the xprofile data fine, but nothing is reaching the database. I’ve tried every possible variation based on the bp-core and Travel-Junkie’s example above, but nothing is working.

    Here’s the plugin:

    <?php
    /*
    Plugin Name: Collection Records
    Plugin URI: -
    Description: Adds a table and page for listing and editing Recylable Collections.
    Version: 1.0
    */

    function collect_install_table() {
    global $wpdb;
    global $bp;

    if ( !empty($wpdb->charset) )
    $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";

    $table_name = $wpdb->prefix . 'collections';
    if($wpdb->get_var("show tables like '$table_name'") != $table_name) {

    $sql = "CREATE TABLE " . $table_name . " (
    id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    sched_date datetime NOT NULL,
    post_date datetime NOT NULL,
    user_id bigint(20) UNSIGNED NOT NULL,
    address_line_1 varchar(150) NOT NULL,
    address_line_2 varchar(150) NOT NULL,
    town varchar(150) NOT NULL,
    state varchar(150) NOT NULL,
    zip_code varchar(150) NOT NULL,
    amount bigint(20) DEFAULT '0' NOT NULL,
    verified tinyint(1) DEFAULT '1' NOT NULL,
    paid tinyint(1) DEFAULT '1' NOT NULL,
    KEY user_id (user_id)
    ) {$charset_collate};";

    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    dbDelta($sql);
    }
    }

    /*Launch database*/
    register_activation_hook(__FILE__,'collect_install_table');

    function bp_collections() {
    global $wpdb;
    global $bp;

    /* bp_is_home() Checks to make sure the current user being viewed equals the logged in user */

    if ( !bp_is_home() && !is_site_admin() )
    return false;

    /* Check for new information*/
    if( isset($_POST['go'] ))
    {
    /* Check the nonce */

    check_admin_referer( 'schedule_collect' );

    if( $_POST['sched_date'] && ! $_POST['address_line_1'] || ! $_POST['sched_date'] && $_POST['address_line_1'] )
    {
    bp_core_add_message( __( 'We need a time and a place!', 'buddypress' ), 'error' );
    $error = true;
    }

    if( ! $error )
    {
    $user_id = $bp->loggedin_user->id;

    if( isset( $_POST['address_line_2'] ) ) {
    $address_line_2 = $_POST['address_line_2'];
    }

    $result = $wpdb->query( $wpdb->prepare("
    INSERT INTO $wpdb->1_collections
    ( sched_date, post_date, user_id, address_line_1, address_line_2, town, state, zip_code )
    VALUES ( %s, %s, %d, %s, %s, %s, %s, %s )",
    $_POST['sched_date'], $_POST['post_date'], $user_id, $_POST['address_line_1'], $address_line_2, $_POST['town'], $_POST['state'], $_POST['zip_code'] ) );

    /* Set the feedback messages */
    if ( $errors )
    bp_core_add_message( __( 'There was a problem calling your pickup, please try again.', 'buddypress' ), 'error' );
    else
    bp_core_add_message( __( 'Thanks for calling a recycling pickup.', 'buddypress' ) );

    }

    bp_core_load_template( apply_filters( 'xprofile_template_display_profile', 'profile/index' ) );
    }
    }
    /* Function to call xprofile Address label */

    function collections_xprofile( $field ) {
    echo bp_collections_get_member_list_xprofile_data( $field );
    }
    function bp_collections_get_member_list_xprofile_data( $field ) {
    global $bp, $site_members_template;
    return xprofile_get_field_data( $field, $site_members_template->member->id );
    }

    ?>

    And the form:

    <?php if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    <form action="" method="post" id="oncall" class="oncall">

    <label for="address">At</label>
    <input type="text" name="address_line_1" id="address_line_1" value="<?php echo bp_collections_get_member_list_xprofile_data('Address Line 1') ?>" />
    <input type="text" name="address_line_2" id="address_line_2" value="<?php echo bp_collections_get_member_list_xprofile_data('Address Line 2') ?>" />
    <input type="text" name="town" id="town" value="<?php echo bp_collections_get_member_list_xprofile_data('Town') ?>" />
    <input type="hidden" name="state" id="state" value="MS" />
    <input type="" name="zip_code" id="zip_code" value="<?php echo bp_collections_get_member_list_xprofile_data('Zip Code') ?>" />
    <br />
    <label for="date">On</label>
    <input type="text" name="sched_date" id="sched_date" value="<?php $tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y")); echo date("Y/m/d", $tomorrow); ?>" />

    <input type="submit" name="go" id="go" value="go"/>
    <input type="hidden" name="post_date" id="post_date" value="<?php $my_t=getdate(date("U")); print("$my_t[weekday], $my_t[month] $my_t[mday], $my_t[year]"); ?> " />

    <?php wp_nonce_field( 'schedule_collect' ) ?>
    </form>
    <?php endwhile; endif; ?>

    It has to be something simple but I’m lost. I’d really appreciate it if someone could take a minute and tell me what’s wrong with the code.

    #62376
    MrMaz
    Participant

    UPDATE:

    The filtering has been consolidated and drastically improved as of revision 2580. Here is an updated example:

    function my_activity_filter( $query_string, $object, $filter, $scope, $page, $search_terms, $extras ) {
    global $bp;

    if ( $object != 'activity' || $scope != 'myclass' || !is_user_logged_in() )
    return $query_string;

    $args = array();
    parse_str( $query_string, $args );
    $args['object'] = $bp->groups->id;
    $args['primary_id'] = function_to_get_group_id_for_logged_in_user();

    return http_build_query( $args );
    }
    add_filter( 'bp_dtheme_ajax_querystring', 'my_activity_filter', 1, 7 );

    As you can see a TON more information about the request is being passed to the filtering, so you can more easily determine what you need to do to handle it properly.

    #62145
    designodyssey
    Participant

    OK, that was way too simple. Thanks. Wouldn’t have found it unless I knew what I was looking for.

    After searching around for this function (and a comment from Burt), I see there are a few others in bp-core.php. Is there any listing of functions that take user_id or group_id and return information? I searched the “Docs” to no avail.

    #62067
    Andy Peatling
    Keymaster

    do_action( 'groups_join_group', $group_id, $user_id );

    #62021
    peterverkooijen
    Participant

    Thanks Devrim. How do I “run” this? Would putting it into bp-custom.php take care of it? I know how to run a SQL query in phpMyAdmin. That’s essentially what this is, right?

    Is there a reason not to try this manually in phpMyAdmin? Is the group_id field connected to/dependant on other fields that are easy to overlook?

    #62017
    Devrim
    Participant

    Hi Peter, I had the same problem, here is the code that will move everything from group_id 1 to group_id 3

    Check the id of the secondary group and change the number 3.

    require_once(‘wp-blog-header.php’);

    $x = $wpdb->get_results(“SELECT * FROM wp_bp_xprofile_fields WHERE group_id=1 and is_required=0”);

    foreach($x as $k=>$v){

    $wpdb->update(‘wp_bp_xprofile_fields’,array(‘group_id’=>3),array(‘id’=>$v->id));

    }

    #61456
    grosbouff
    Participant

    Seems this has something to do with function has_fields() :

    function has_fields() {

    $has_data = false;

    for ( $i = 0; $i < count( $this->group->fields ); $i++ ) {

    $field = &$this->group->fields[$i];

    if ( $field->data->value != null ) {

    $has_data = true;

    }

    }

    if ( $has_data )

    return true;

    return false;

    }

    print_r($field) returns

    teststdClass Object ( [id] => 1 [name] => Name [type] => textbox [group_id] => 1 ) stdClass Object ( [id] => 2 [name] => Name [type] => textbox [group_id] => 1 ) stdClass Object ( [id] => 3 [name] => First Name [type] => textbox [group_id] => 1 ) stdClass Object ( [id] => 4 [name] => Both Names [type] => textbox [group_id] => 1 )

    print_r($field->data) returns FALSE…

    #61444
    vusis
    Participant

    I have a problem:

    how do i pickup the group_id of the forum topic. Thant way i can build the link to the from topic from the home page.

    #60353
    ajdinb
    Participant

    Just an update. I’m using LDAP Authentication Plug-in; Plugin URI: http://wpmuldap.frozenpc.net

    I found that if I add a user first via WPMU admin CP then permissions work OK. However if the user is created on first login attempt the the issue occurs. I’ve reported this at the plugins site but no reply so far.

    http://sourceforge.net/tracker/?func=detail&aid=2909982&group_id=196841&atid=959074

    There seam to be other LDAP plugins (https://wordpress.org/extend/plugins/simple-ldap-login/ and https://wordpress.org/extend/plugins/simple-ldap-authentication/) which I did not try.

    #60124
    kineda
    Participant

    Thanks. That clears things up. The only other problem I’ve encountered is after I deactivate the BuddyPress plugin and re-activate it, I’ll get the follow db errors:

    WordPress database error: [Duplicate key name ‘useritem’]

    ALTER TABLE wp_bp_notifications ADD KEY useritem (user_id, is_new)

    WordPress database error: [Table ‘wp_bp_activity’ already exists]

    RENAME TABLE wp_bp_activity_user_activity_cached TO wp_bp_activity

    WordPress database error: [Duplicate entry ‘1’ for key 1]

    INSERT INTO wp_bp_xprofile_groups VALUES ( 1, ‘Base’, ”, 0 );

    WordPress database error: [Duplicate entry ‘1’ for key 1]

    INSERT INTO wp_bp_xprofile_fields ( id, group_id, parent_id, type, name, is_required, can_delete ) VALUES ( 1, 1, 0, ‘textbox’, ‘Name’, 1, 0 );

    #59912
    Anonymous User 96400
    Inactive

    Just had a quick look. You might be able to just get away with changing the group_id field in wp_bp_xprofile_fields to the id of the new group. The data table only seems to be looking for the id field. You can do that in phpMyAdmin. Try it locally, though, first if at all possible.

    #59885
    Anonymous User 96400
    Inactive

    @Bowe

    setting up different group types is fairly easy. You just have to attach some groupmeta to the group, that basically let you add as many types as you’d like. Then you just check the metadata to figure out what type of group you’re in. Using the groups API you can then add different functionality for different groups.

    I’ve written a types-plugin for one of my sites. It doesn’t have an interface, though. The 3 types I needed are hardcoded into it, so it’s really not suited for a release at the moment. There’s also a lot of more stuff, like a shopping cart, part of that plugin. So, I’ve stripped the functions needed for group types out (hopefully al of them).

    First we need to add the addtional fields to our registration form:

    function sv_add_registration_group_types()
    {
    ?>
    <div id="account-type" class="register-section">
    <h3 class="transform"><?php _e( 'Choose your account type (required)', 'group-types' ) ?></h3>

    <script type="text/javascript" defer="defer">
    jQuery(document).ready(function(){
    jQuery("#account-type-normal_user").attr("checked", true);
    jQuery("#group-details").hide();
    jQuery("#account-type-type_one,#account-type-type_two,#account-type-type_three").click(function(){
    if (jQuery(this).is(":checked")) {
    jQuery("#group-details").slideDown("slow");
    } else {
    jQuery("#group-details").slideUp("slow");
    }
    });
    jQuery("#account-type-normal_user").click(function(){
    if (jQuery(this).is(":checked")) {
    jQuery("#group-details").slideUp("slow");
    } else {
    jQuery("#group-details").slideDown("slow");
    }
    });
    });
    </script>

    <?php do_action( 'bp_account_type_errors' ) ?>
    <label><input type="radio" name="account_type" id="account-type-normal_user" value="normal_user" checked="checked" /><?php _e( 'User', 'group-types' ) ?></label>
    <label><input type="radio" name="account_type" id="account-type-type_one" value="type_one" /><?php _e( 'Type 1', 'group-types' ) ?></label>
    <label><input type="radio" name="account_type" id="account-type-type_two" value="type_two" /><?php _e( 'Type 2', 'group-types' ) ?></label>
    <label><input type="radio" name="account_type" id="account-type-type_three" value="type_three" /><?php _e( 'Type 3', 'group-types' ) ?></label>

    <div id="group-details">
    <p><?php _e( 'We will automatically create a group for your business or organization. This group will be tailored to your needs! You can change the description and the news later in the admin section of your group.', 'group-types' ); ?></p>

    <?php do_action( 'bp_group_name_errors' ) ?>
    <label for="group_name"><?php _e( 'Group Name', 'scuba' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label>
    <input type="text" name="group_name" id="group_name" value="" />
    <br /><small><?php _e( 'We suggest you use the name of your business or organization', 'group-types' ) ?></small>

    <label for="group_desc"><?php _e( 'Group Description', 'scuba' ) ?></label>
    <textarea rows="5" cols="40" name="group_desc" id="group_desc"></textarea>
    <br /><small><?php _e( 'This description will be visible on your group profile, so it could be used to present your mission statement for example.', 'group-types' ) ?></small>

    <label for="group_news"><?php _e( 'Group News', 'scuba' ) ?></label>
    <textarea rows="5" cols="40" name="group_news" id="group_news"></textarea>
    <br /><small><?php _e( 'Enter any news that you want potential members to see.', 'group-types' ) ?></small>
    </div>
    </div>
    <?php
    }
    add_action( 'bp_before_registration_submit_buttons', 'sv_add_registration_group_types' );

    Then we have to validate things and add some usermeta when a regitration happens:

    /**
    * Add custom userdata from register.php
    * @since 1.0
    */
    function sv_add_to_signup( $usermeta )
    {
    $usermeta['account_type'] = $_POST['account_type'];

    if( isset( $_POST['group_name'] ) )
    $usermeta['group_name'] = $_POST['group_name'];

    if( isset( $_POST['group_desc'] ) )
    $usermeta['group_desc'] = $_POST['group_desc'];

    if( isset( $_POST['group_news'] ) )
    $usermeta['group_news'] = $_POST['group_news'];

    return $usermeta;
    }
    add_filter( 'bp_signup_usermeta', 'sv_add_to_signup' );

    /**
    * Update usermeta with custom registration data
    * @since 1.0
    */
    function sv_user_activate_fields( $user )
    {
    update_usermeta( $user['user_id'], 'account_type', $user['meta']['account_type'] );

    if( isset( $user['meta']['group_name'] ) )
    update_usermeta( $user['user_id'], 'group_name', $user['meta']['group_name'] );

    if( isset( $user['meta']['group_desc'] ) )
    update_usermeta( $user['user_id'], 'group_desc', $user['meta']['group_desc'] );

    if( isset( $user['meta']['group_news'] ) )
    update_usermeta( $user['user_id'], 'group_news', $user['meta']['group_news'] );

    return $user;
    }
    add_filter( 'bp_core_activate_account', 'sv_user_activate_fields' );

    /**
    * Perform checks for custom registration data
    * @since 1.0
    */
    function sv_check_additional_signup()
    {
    global $bp;

    if( empty( $_POST['account_type'] ) )
    $bp->signup->errors['account_type'] = __( 'You need to choose your account type', 'group-types' );

    if( empty( $_POST['group_name'] ) && $_POST['account_type'] != 'normal_user' )
    $bp->signup->errors['group_name'] = __( 'You need to pick a group name', 'group-types' );

    if( ! empty( $_POST['group_name'] ) && $_POST['account_type'] != 'normal_user' )
    {
    $slug = sanitize_title_with_dashes( $_POST['group_name'] );
    $exist = groups_check_group_exists( $slug );
    if( $exist )
    $bp->signup->errors['group_name'] = __( 'This name is not available. If you feel this is a mistake, please <a href="/contact">contact us</a>.', 'group-types' );
    }
    }
    add_action( 'bp_signup_validate', 'sv_check_additional_signup' );

    And then we set up the group for the user (there are some constants in this function, so you’ll need to change that):

    /**
    * Create custom groups for skools, biz and org accounts
    * @since 1.0
    */
    function sv_init_special_groups( $user )
    {
    global $bp;

    // get account type
    $type = get_usermeta( $user['user_id'], 'account_type' );

    if( $type == 'normal_user' )
    {
    // Do nothing
    }
    elseif( $type == 'type_one' || $type == 'type_two' || $type == 'type_three' )
    {
    // get some more data from sign up
    $group_name = get_usermeta( $user['user_id'], 'group_name' );
    $group_desc = get_usermeta( $user['user_id'], 'group_desc' );
    $group_news = get_usermeta( $user['user_id'], 'group_news' );

    $slug = sanitize_title_with_dashes( $group_name );

    // create dive skool group
    $group_id = groups_create_group( array(
    'creator_id' => $user['user_id'],
    'name' => $group_name,
    'slug' => $slug,
    'description' => $group_desc,
    'news' => $group_news,
    'status' => 'public',
    'enable_wire' => true,
    'enable_forum' => true,
    'date_created' => gmdate('Y-m-d H:i:s')
    )
    );
    // add the type to our group
    groups_update_groupmeta( $group_id, 'group_type', $type );

    // delete now useless data
    delete_usermeta( $user['user_id'], 'group_name' );
    delete_usermeta( $user['user_id'], 'group_desc' );
    delete_usermeta( $user['user_id'], 'group_news' );

    // include PHPMailer
    require_once( SV_MAILER . 'class.phpmailer.php' );

    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = SV_SMTP;

    $auth = get_userdata( $user['user_id'] );
    $profile_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $slug . '/admin';

    $message = sprintf( __( 'Hello %s,

    we have created a group for your business or organization. To get more out of your presence on Yoursitenamehere please take some time to set it up properly.

    Please follow this link to fill in the rest of your profile: %s

    We wish you all the best. Should you have any questions regarding your new group, please contact us at support@yoursitenamehere.com.

    Your Yoursitenamehere Team', 'group-types' ), $auth->display_name, $profile_link );

    $mail->SetFrom("support@yoursitenamehere.com","Yoursitenamehere");
    $mail->AddAddress( $auth->user_email );

    $mail->Subject = __( 'Your new group pages on Yoursitenamehere', 'group-types' );
    $mail->Body = $message;
    $mail->WordWrap = 75;
    $mail->Send();
    }
    }
    add_action( 'bp_core_account_activated', 'sv_init_special_groups' );

    When you write a group extension we’ll have to swap the activation call with a function like the one below to be able to check for group types.

    /**
    * Replacement activation function for group extension classes
    */
    function activate_type_one()
    {
    global $bp;
    $type = groups_get_groupmeta( $bp->groups->current_group->id, 'group_type' );
    if( $type == 'type_one' )
    {
    $extension = new Group_Type_One;
    add_action( "wp", array( &$extension, "_register" ), 2 );
    }
    }
    add_action( 'plugins_loaded', 'activate_type_one' );

    The last thing we need to do is add our group type names to group and directory pages:

    /**
    * Modify the group type status
    */
    function sv_get_group_type( $type, $group = false )
    {
    global $groups_template;

    if( ! $group )
    $group =& $groups_template->group;

    $gtype = groups_get_groupmeta( $group->id, 'group_type' );
    if( $gtype == 'type_one' )
    $name = __( 'Type 1', 'group-types' );

    elseif( $gtype == 'type_two' )
    $name = __( 'Type 2', 'group-types' );

    elseif( $gtype == 'type_three' )
    $name = __( 'Type 3', 'group-types' );

    else
    $name = __( 'User Group', 'group-types' );

    if( 'public' == $group->status )
    {
    $type = sprintf( __( "%s (public)", "group-types" ), $name );
    }
    elseif( 'hidden' == $group->status )
    {
    $type = sprintf( __( "%s (hidden)", "group-types" ), $name );
    }
    elseif( 'private' == $group->status )
    {
    $type = sprintf( __( "%s (private)", "group-types" ), $name );
    }
    else
    {
    $type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
    }

    return $type;
    }
    add_filter( 'bp_get_group_type', 'sv_get_group_type' );

    /**
    * Modify the group type status on directory pages
    */
    function sv_get_the_site_group_type()
    {
    global $site_groups_template;

    return sv_get_group_type( '', $site_groups_template->group );
    }
    add_filter( 'bp_get_the_site_group_type', 'sv_get_the_site_group_type' );

    It’s quite a bit of code, but it should get you started. This hasn’t been tested with 1.2 btw.

    #58673
    vusis
    Participant

    hey guys i cant seem to figure this one out hey; i’ve tried to patch the bp-groups.php file but i get a

    #1 HUNK Failed at 449 – please see my reject file

    ***************

    *** 453,459 ****

    bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );

    }

    – if ( !$bp->groups->new_group_id = groups_create_group( array( ‘group_id’ => $bp->groups->new_group_id, ‘name’ => $_POST[‘group-name’], ‘description’ => $_POST[‘group-desc’], ‘news’ => $_POST[‘group-news’], ‘slug’ => groups_check_slug( sanitize_title($_POST[‘group-name’]) ), ‘date_created’ => time() ) ) ) {

    bp_core_add_message( __( ‘There was an error saving group details, please try again.’, ‘buddypress’ ), ‘error’ );

    bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );

    }

    — 453,474 —-

    bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );

    }

    + $group_details = array(

    + ‘group_id’ => $bp->groups->new_group_id,

    + ‘name’ => $_POST[‘group-name’],

    + ‘description’ => $_POST[‘group-desc’],

    + ‘news’ => $_POST[‘group-news’],

    + ‘slug’ => groups_check_slug( sanitize_title($_POST[‘group-name’]) ),

    + ‘date_created’ => time() );

    +

    + /* Allow plugins to halt group creation for whatever reason. On doing this the plugin

    + should use the bp_core_add_message function to inform the user why the group creation

    + has failed.

    + N.B. The data passed in $new_group is unsanitised. */

    + if ( ! apply_filters( ‘bp_allow_create_group’, true, $group_details ) )

    + return bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create’ );

    +

    + if ( !$bp->groups->new_group_id = groups_create_group( $group_details ) ) {

    bp_core_add_message( __( ‘There was an error saving group details, please try again.’, ‘buddypress’ ), ‘error’ );

    bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );

    }

    i’m not too sure what that means and how it can be fixed? :(

Viewing 25 results - 501 through 525 (of 564 total)
Skip to toolbar