Documentation Available?

Is there any documentation available of which functions can be implemented for theme development? A few that I would like to know are:
- function to enroll students
- function to withdraw students


  • Tyler Postle

    Hey Susan,

    Hope you're doing well today and thanks for your question!

    We're actually working on creating developer docs, still working out the best system to do so; however, we do know that's it becoming more and more requested :slight_smile:

    There are functions for enrolling students inside coursepress.php around line 2567.

    I'm not seeing them for withdrawing, I'll flag the developer here so we can get his feedback, he will be the best person to ask on this.

    Keep in mind, developer response times can be a bit slower as they have a lot of developer side responsibilities.

    Let us know if you have any further questions in the meantime!

    All the best,

  • Marko Miljus

    Hi @Susan,

    the best and quickest way to implement CoursePress features in other themes would be via shortcodes.

    You can see shortcode documentation within the plugin: CoursePress Pro > Settings > Shortcodes

    For instance, you would use this shortcode [course_join_button] for enrollment and [course_action_links] for course withdrawal.

    Let me know if you need any additional assistance here and I'll be happy to help you.


  • Susan

    So we are using SAML to handle our user login. This is due to the ability to pass SAML attributes associated with each user.

    What we are needing to do is enroll/withdraw the users to specific courses based upon these SAML attributes. So we need to hook into the native login function and perform some logic to determine which courses if any a user gets access to and then enroll them in those courses accordingly. We also need to withdraw students as well in a similar fashion.

    This is the reason I'm hoping to have some developer documentation available, so that I can perform some of the CoursePress functionality using native functions rather than writing directly to the database or something possibly worse.

    Hopefully you were able to follow along. I know it might have been a little cryptic as I was trying to spare you from all the nitty, gritty details.

    This plugin has been a lifesaver so far and the support has been exceptional. Nearly everything we've needed/requested has been implemented and I'm still holding out for the capability to have Tags along with the new Course Categories.

  • Tyler Postle

    Hey Susan,

    Thanks for your response here! I've passed that info onto one of our other CoursePress developers that has been recently adding in hooks, he will know best on this :slight_smile:

    Far as developer docs go, this is still in the planning stages, so it won't be available for awhile yet - but any questions like this definitely just ask us here in the meantime and we'll get one of our developers to help you out if we're unable too :slight_smile:

    Course Tags is a good idea! I believe it's already been requested but I'll mark is as a request again just in-case.

    Talk to you soon Susan!

    All the best,

  • Rheinard

    Hi @Susan,

    CoursePress does already have a number of things in place that will allow you to do some of what you want to do. Most of this is in our Student[] class (includes/classes/class.student.php).

    Whats interesting to note about Student[] is that it extends a normal WP_User[] object by adding some new features. To integrate your theme/plugin with CoursePress you'd want to make sure that CoursePress has already loaded. Probably the best way to do this would be to add the following to your theme's functions.php or your custom plugin.

    add_action( 'plugins_loaded', '20141218_coursepress_integration' );
        function 20141218_coursepress_integration() {
        	// SAML / CoursePress code can go in here...

    At this point you want to make use of the student class. If your SAML data has the same ID as the WordPress user, then you can do the following to get access to that Student.

    // Create a student object
        $student = new Student( $user_id );

    Now you can do a number of things with the student. For example to get the IDs of all the enrolled courses as an array you can:

    $enrolled_courses = $student->get_enrolled_courses_ids();

    To see if the user is enrolled in a particular course you can:

    $is_enrolled = $student->user_enrolled_in_course( $course_id );

    If you want to enroll the student in a course you could use the above line in combination with the following:

    if( ! $is_enrolled ) {
            $student->enroll_in_course( $course_id );

    Similarly, if you want to withdraw a student you can:

    if( is_enrolled ) {
            $student->withdraw_from_course( $course_id );

    If you want to be a bit more brutal, you can withdraw a student from all courses with:


    A few actions are also available. When a student gets enrolled in a course you can hook the following action:

    add_action( 'coursepress_student_enrolled', '20141218_user_enrolled', 10, 2 );
        function 20141218_user_enrolled( $student_id, $course_id ) {
        	// Update SAML if needed

    When a student withdraws there are a few actions that fire as well that can be hooked as follows:

    add_action( 'student_withdraw_from_course_instructor_notification', '20141218_withdrawn_instructor_list', 10, 3 );
        add_action( 'coursepress_student_withdrawn', '20141218_withdrawn', 10, 2 );
        function 20141218_withdrawn_instructor_list( $student_id, $course_id, $instructor_array ) {
        	// Some code relevant to students withdrawing and instructors
        function 20141218_withdrawn( $student_id, $course_id ) {
        	// Update SAML if needed

    For another example, look at coursepress.php around line 1600: signup_create_user(). This is an example of how you could use the Student object to add a new user.

    I hope this is what you were after. If there is anything else that you'd like to see, just let us know and we'll see if its already planned or add it to our feature request list.


  • Susan

    Is it possible to generate a report of which users have visited a particular course? I don't want to know if they are enrolled in a course, but if they've actually visited a course. Is there already a built in function to handle this type of a report?

    I've looked around in the code to see if there is a function that does this and couldn't find one. I might have missed it or not looked in the right file.

    • Susan

      Thank you Tyler. The reason I asked is that I see there is an entry in the database for units visited that is added to the usermeta table ('visited_units'), however, this does not specify the sub site via the WP_prefix like in a lot of the other options. This leads me to believe that it is an artifact from code that has since been removed. I also see other code that is relevant to the units and pages, but those meta keys do not have the WP_prefix. This is an unfortunate slight as it is all too possible that different courses could have the same ID on different sub-sites, but since the User tables are shared there is obviously some possibilities for overlap. It is my suggestion that everything be given a WP_prefix in the usermeta table. This would be a relatively simple change to make but would ensure no compatibility issues going forward.

      Also as a question of curiosity what is the developers take on merge requests? If we were to make changes to the plugin could we submit these changes to the plugin developers to possibly be merged into the plugin core code?

  • Vaughan

    Hi Susan,

    I'll let @Rheinard know of your suggestion.

    with regards to merge requests, our dev systems aren't open to the public, but if you have any code changes that you'd like us to checkout, just let us know on the forum & we can pass these along to the developer for sonsideration, though we can't guarantee that the developers will ultimately add them, however we will look at them & if they're someething that many users will benefit from it's likely the developers would consider them.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.