Plugin: BuddyPress ScholarPress Courseware

Join this plugin group to follow comments, support topics and reviews.

Courseware Teacher Role (16 posts)

Started 1 year, 3 months ago by: Chris Kenniburg

  • Profile picture of Chris Kenniburg kennibc said 1 year, 3 months ago:

    Here is the issue I am having… There is no good way to make a user the teacher role for Courseware. In my setup I need to disable messaging because I work in a K12 environment and when someone tries to apply for teacher they get a page error.

    Does anyone know how to make it so that who ever is Admin for the Group can also be the Teacher and edit the Courseware options for the group automatically?

  • Profile picture of Stas Sușcov Stas Suscov said 1 year, 3 months ago:

    You can simply remove that option from users.
    There’s a thread with some code:

    http://buddypress.org/community/groups/buddypress-courseware/forum/topic/remove-apply-to-be-a-teacher-option/

    I will post another piece of code that will automatically make a teacher for his own group, does that sound ok?

  • Profile picture of Chris Kenniburg kennibc said 1 year, 3 months ago:

    I would really like that Stas! The code that makes the group admin the teacher automatically would be ideal.

    As for removing the option for them to request being a teacher, couldn’t I just remove that from the Buddypress Profile Dashboard page? I can see the courseware role option there and I could just delete it?

  • Profile picture of Stas Sușcov Stas Suscov said 1 year, 3 months ago:

    No, do not delete it, it will be restored anyway.

    Here’s the code you need to automatically create teachers when they create a group.
    First function will simply hide the Courseware edit profile option, so you can delete it if you want.

    <?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' );
    
    ?>
  • Profile picture of Chris Kenniburg kennibc said 1 year, 3 months ago:

    THANK YOU STAS!

    Please forgive my ignorance, but where do I add this code? Do I just copy it to a file and then drop it in the plugins folder?

  • Profile picture of Stas Sușcov Stas Suscov said 1 year, 3 months ago:

    Yep :)

  • Profile picture of Chris Kenniburg kennibc said 1 year, 3 months ago:

    I just did what I mentioned above and tried to activate the plugin and got this error:
    Parse error: syntax error, unexpected T_STRING in wp-content/plugins/courseware.php on line 14

  • Profile picture of Stas Sușcov Stas Suscov said 1 year, 3 months ago:
    wp_die( 'Please go back, this profile group can't be edited!' );

    there’s a (‘) missing!
    this formatting sucks a bit :)

  • Profile picture of Stas Sușcov Stas Suscov said 1 year, 3 months ago:

    nvm, just take this code:

    https://gist.github.com/822628

  • Profile picture of Chris Kenniburg kennibc said 1 year, 3 months ago:

    AWESOME!
    I am totally geeked about using Courseware! My wife is not going to be happy with me fooling around with Courseware this weekend!

    Thank you very, very much for your time.

    This is a great project and if you need help promoting it I would love to help. I am going to finish making some changes to my buddypress themes and I am going to start promoting this with teachers.
    Can’t wait to show this new tool to them.

  • Profile picture of Stas Sușcov Stas Suscov said 1 year, 3 months ago:

    Nice to hear that. :)
    Keep it up!

  • Profile picture of PiManIII PiManIII said 10 months, 2 weeks ago:

    Awesome!

    I know that this code may be replaced in future updates, so will this option be included in the future updates?

  • Profile picture of Stas Sușcov Stas Suscov said 10 months, 2 weeks ago:

    cw_make_group_admins_teacher() is an example of how you can use the Courseware API to fix customize the workflow, if will not (and probably never be) included in core, as I tend to keep things simple and light.

    It is plugins territory to extend Courseware with such options, all I can do is offer a rich filters/actions integration.

  • Profile picture of gertzse gertzse said 8 months, 2 weeks ago:

    Stas, forgive my ignorance, but i am completely confused about roles and users in Buddypress and Courseware. I want to be able to add users as either teachers or students. I have watched your video several times and read the documentation, but i just cannot figure it out. ;-( Please help!

  • Profile picture of Stas Sușcov Stas Suscov said 8 months, 2 weeks ago:

    As an administrator, go to user profile page you want to make a teacher.
    You should get to a page like

    http://your-website.com/members/test/profile/

    Now edit the url to point to

    http://your-website.com/members/test/profile/edit

    Click on the Courseware tab that should be visible in the page now.
    And select the role from the available.

    Hope this helps.