Coursepress custom fields in certificates

Hello,

I have 2 questions acout Coursepress Pro functionality.
1. How can I add additional fields for students (birthday and profession)? Students must enter these data during registration.
2. How can I add this information to final certificate (e.g. Student Name, birthday, Profession?)

  • Dimitris

    Hello there Michail,

    hope you're doing good today and thanks for reaching us!

    1. How can I add additional fields for students (birthday and profession)? Students must enter these data during registration.

    There's no way provided by CoursePress itself, you can disable the login/register forms it provides though with next setting
    https://monosnap.com/file/gOSBMRv1mUiI5sLLRMCmCLFzMwEYSX
    and then install and activate the famous BuddyPress plugin, which can be used to insert additional profile fields.

    2. How can I add this information to final certificate (e.g. Student Name, birthday, Profession?)

    Certificates are using only a predefined set of macros, so there's no support of additional fields there.
    Please let me know, if you're going to use the above BuddyPress approach, so I could then ping our Second Level Support team to let us know if it's possible to add extended BuddyPress profile fields in CoursePress certificates.

    Warm regards,
    Dimitris

  • Dimitris

    Hello there Michail,

    appreciate your kind words here!

    I've already created a request towards our Second Level Support team, on how to add additional profile fields in CoursePress certificates.
    I can't promise that this will be doable, at least in a timely manner or if it's going to be considered custom development, so a developer of yours should implement it. For the later, or in case you urgently need this, you can always advise our jobs board page, Jobs & Pros (no WPMUDEV staff included there).
    Reference: https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-1 ("WPMU DEV Support vs. Custom Development")

    Warm regards,
    Dimitris

    • Dimitris

      That's something similar that should be made, it includes BuddyPress variables though, instead of CoursePress ones (like grades).
      Our developers will keep us posted on this as soon as possible!
      Please keep in mind that their response times are wider than ours here in support forums, as they're working from older to newer request.
      Your patience on this is highly appreciated!

      Take care,
      Dimitris

      • Michail

        Hello,

        I successfully installed Buddypress - it has options to make extra fields (birthday, profession in my case).
        All I need - is to output these fields in Coursepress certificate.
        On "single wordpress pages" I use "xprofile_get_field_data" function and it gives output, for example:

        $profession_field = xprofile_get_field_data( '2', '3', $multi_format = 'comma' );

        Gives me profession of user with ID=3.
        As I see from database tables, Coursepress variable $student_id it the same as Buddypress User ID.

        When I try to implement the same string in code provided below, I get empty data. Example:
        The question is - why output is empty and if there are any additional includes I should use?

        Code I used for my custom "plugin" look like:

        <?php
        /**
        * Plugin Name: BuddyPress user Data on Certificate
        * Description: Add BuddyPress user data on certificate_tokens
        */

        add_filter( 'coursepress_certificate_fields', 'percentage_fields_on_certificate' );
        add_filter( 'coursepress_basic_certificate_html', 'modify_basic_certificate_html', 10, 3 );
        add_filter( 'coursepress_basic_certificate_vars', 'percentage_to_certificate_vars', 10, 1 );

        function percentage_fields_on_certificate($fields, $student, $course){
        $course_grade = 0;
        if ( class_exists ( 'CoursePress_Data_Student' ) ) {
        $course_grade = CoursePress_Data_Student::average_course_responses( $student_id, $course_id );
        }
        elseif ( class_exists( 'Student' ) ) {
        $student = new Student( $student_id );
        if ( $student->is_course_complete( $student_id, $course_id ) ) {
        $course_grade = get_avarage_response_grade( $course_id );
        }
        }

        return array_merge( $fields, array( 'assessment_percentage' => $course_grade ) );
        }

        function modify_basic_certificate_html( $html, $course_id, $student_id ) {
        $profession_field = xprofile_get_field_data( '2', '3', $multi_format = 'comma' );
        return $html . '<div id="Profession"> Profession - '. $profession_field . ' </div>';
        }

        function percentage_to_certificate_vars( $certificate_tokens ) {
        return array_merge( $certificate_tokens, array( 'assessment_percentage'=>'' ) );
        }

        ?>