Created
February 11, 2011 16:49
-
-
Save stas/822628 to your computer and use it in GitHub Desktop.
Courseware hacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Hide Courseware option and make group admins teacher | |
Author: stas | |
*/ | |
function cw_hide_group_profilegroup( $current_group ){ | |
// Check if Courseware is enabled | |
if( !class_exists( 'BPSP_Roles' ) ) | |
return $current_group; | |
$courseware_profilegroup = BPSP_Roles::field_group_id_from_name( __( 'Courseware', 'bpsp' ) ); | |
if( $courseware_profilegroup == $current_group ) | |
wp_die( 'Please go back, this profile group can\'t be edited!' ); | |
return $current_group; | |
} | |
add_filter( 'bp_get_current_profile_group_id', 'cw_hide_group_profilegroup' ); | |
function cw_make_group_admins_teacher() { | |
global $bp; | |
$user_id = $bp->loggedin_user->id; | |
// Check if Courseware is enabled | |
if( !class_exists( 'BPSP_Roles' ) ) | |
return; | |
remove_all_filters( 'bp_xprofile_field_get_children' ); | |
xprofile_set_field_data( __( 'Role' ), $user_id, __( 'Teacher' ) ); | |
do_action( 'courseware_new_teacher_added', $user_id ); | |
} | |
add_action( 'groups_created_group', 'cw_make_group_admins_teacher' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment