May 15, 2015 - Development

Purging old data

Neeed to check the `insidelaw`.`banner`.`admin` `item`='last_update_201508' and delete users/classes/etc that have were last updated before that time.

Classes (ref: for 201505, `insidelaw`.`banner`.`class` `id`='12221' is a cancelled class, last updated on May 1.)
Students: (ref: all `insidelaw`.`banner`.`class_rolls` where `semester`='201505' and `updated` < 2015-05-20)

Faculty Support

Adding faculty support to every class would be awkward and does not seem necessary. Right now, there is a "back door" way for people assigned the role "Faculty Support" to post docs, but they cannot send mass emails. The key may be to alter the function of "groups_is_user_mod" function, but further research is needed.

Bug making admins programatically

Discovered bug that using the below does not work - if the user "is_admin" already, this save will clear the "is_admin" flag. Ended up writing directly to table, bypassing the BP API.

$bp_member->group_id = $bp_group_id;
$bp_member->user_id = $user_id;
$bp_member = new BP_Groups_Member;
$bp_member->is_admin = 1;
$saved = $bp_member->save();

 

From https://buddypress.org/support/topic/resolved-programmatically-creating-a-group/

    function create_a_group() {

$new_group = new BP_Groups_Group;

$new_group->creator_id = 1;
$new_group->name = ‘test’;
$new_group->slug = ‘test’;
$new_group->description = ‘nothing’;
$new_group->news = ‘whatever’;
$new_group->status = ‘public’;
$new_group->is_invitation_only = 1;
$new_group->enable_wire = 1;
$new_group->enable_forum = 1;
$new_group->enable_photos = 1;
$new_group->photos_admin_only = 1;
$new_group->date_created = current_time(‘mysql’);
$new_group->total_member_count = 1;
$new_group->avatar_thumb = ‘some kind of path’;
$new_group->avatar_full = ‘some kind of path’;

	$saved = $new_group -> save();

if ( $saved )
{
$id = $new_group->id;
groups_update_groupmeta( $id, 'total_member_count', 1 );
groups_update_groupmeta( $id, 'last_activity', time() );
groups_update_groupmeta( $id, 'theme’, ‘buddypress' );
groups_update_groupmeta( $id, 'stylesheet’, ‘buddypress' );

} else {
return false;
}

The struck-thru about are obsolete.

 

Adding BP users: When you register a user that way, they will not show up in BuddyPress’ members directory until they login.

You can bypass this programatically by adding a ‘last_activity’ user meta entry.

function make_user_active( $user_id ) {
	bp_update_user_last_activity( $user_id );
}
add_action ('user_register', 'make_user_active', 1, 11);

For Groups (1L, 2L, 3L etc.):

Groups_User_Group::create( array( 'user_id' => $user_id, 'group_id' => $group_id ) );

After digging in the source a little, I am guessing that this is the way to remove:

Groups_User_Group::delete ( $user_id, $group_id ) );

Comments are closed.