• Resolved wesley1066

    (@wesley1066)


    Is there a way to put the instructor’s name, date and verification code on the certificate?

Viewing 13 replies - 1 through 13 (of 13 total)
  • sliontos

    (@sliontos)

    Hi, wesley1066.

    Try this to add the date of certificate when generated…

    • Go to ‘/wp-content/plugins/masterstudy-lms-learning-management-system/stm-lms-templates’ and open with text editor the file ‘stm-lms-certificates-generator.php’.
    • After that add the following code after ‘$username = $user[‘login’];’ after line 14:

      $_option_name = “_cert_date_” . $username . “_” . str_replace (“”, “-“, get_the_title ( $course_id ) );
      $_date = get_option( $_option_name );
      if ( empty( $_date ) ) {
      $_date = date( “l j F, Y” );
      add_option ( $_option_name, date( “Y-m-d” ), “”, “no” );
      } else
      $_date = date( “l j F, Y”, strtotime ( $_date ) );

    • Now find and replace the following code:

      Before:
      $shortcodes = array(“{username}”, “{date}”, “{course}”, “{user_first_name}”,
      “{user_last_name}”);
      $shortcode_values = array($username, “date”, get_the_title($course_id), $first_name,
      $last_name);

      After:
      $shortcodes = array(“{username}”, “{date}”, “{course}”, “{user_first_name}”,
      “{user_last_name}”);
      $shortcode_values = array($username, $_date, get_the_title($course_id), $first_name,
      $last_name);

    …that’s all…

    Now you can add the shortcode {date} where ever you want at certificate settings.
    Let me know if that works.

    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    sliontos

    (@sliontos)

    …[UPDATED]….added the Author name….

    Also right after ‘$username = $user[‘login’];’ at line 14 add the code:

    $get_course_data = stm_lms_get_user_course($user[“id”], $course_id, array(), “”);
    $post_author_id = get_post_field( “post_author”, $get_course_data[0][“course_id”] );
    $instructor = get_the_author_meta( “display_name” , $post_author_id );

    …and replace now the following:

    OLD:
    $shortcodes = array(“{username}”, “{date}”, “{course}”, “{user_first_name}”,
    “{user_last_name}”);
    $shortcode_values = array($username, $_date, get_the_title($course_id), $first_name,
    $last_name);

    NEW:
    $shortcodes = array(“{username}”, “{date}”, “{course}”, “{user_first_name}”, ”
    {user_last_name}”,”{instructor}”);
    $shortcode_values = array($username, $_date, get_the_title($course_id), $first_name,
    $last_name, $instructor);

    …that’s it….now you can use the shortcode {instructor} also….

    • This reply was modified 4 years ago by sliontos.
    Thread Starter wesley1066

    (@wesley1066)

    Thank you very much, I work perfectly, big hugs!

    Sorry my english, I’m Brazilian

    sliontos

    (@sliontos)

    @wesley1066…you welcome!

    you can change the date format at this line ‘$_date = date( “l j F, Y”, strtotime ( $_date ) );’ as you like. Just follow the link.

    PHP Date

    • This reply was modified 4 years ago by sliontos.
    xezormarkv

    (@xezormarkv)

    {course} doesn’t work and doesn’t show anything on the certificate, what can I do?

    Thread Starter wesley1066

    (@wesley1066)

    @xezormarkv

    ————-Code created by @sliontos——————–

    $username = $user[‘login’];
    $get_course_data = stm_lms_get_user_course($user[“id”], $course_id, array(), “”);
    $post_author_id = get_post_field( “post_author”, $get_course_data[0][“course_id”] );
    $instructor = get_the_author_meta( “display_name” , $post_author_id );

    $_option_name = ‘_cert_date_’ . $username . ‘_’ . get_the_title ( $course_id );
    $_date = get_option( $_option_name );
    if ( empty( $_date ) ) {
    $_date = date( ‘l j F, Y’ );
    add_option ( $_option_name, date( ‘Y-m-d’ ), ‘no’ );
    } else
    $_date = date( ‘l j F, Y’, strtotime ( $_date ) );

    $shortcodes = array(“{username}”, “{date}”, “{course}”, “{user_first_name}”, “{user_last_name}”, “{instructor}”);
    $shortcode_values = array($username, $_date, get_the_title($course_id), $first_name, $last_name, $instructor);
    ————————————————————

    IN STM LMS > Certificate > Certificate Text

    Is like this…………………….

    has qualifications and achieved all requirements of {course}

    End Date: {date}
    Instructor: {instructor}

    The end……………………………….

    here’s a link of how it was: https://uday.com.br/cursos/wp-content/uploads/2020/04/certificate.pdf

    Thread Starter wesley1066

    (@wesley1066)

    @sliontos Thank you very much! 🙂

    xezormarkv

    (@xezormarkv)

    @wesley1066 Thank you so much!!

    sliontos

    (@sliontos)

    @wesley1066 & @xezormarkv Thank you very much guys!

    sliontos

    (@sliontos)

    [UPDATED] @wesley1066 & @xezormarkv

    Because the {date} is the generated date of certification and that is not the real date of course completion I have added the following code…

    ….To work right is IMPORTANT to replace the following code in /wp-content/plugins/masterstudy-lms-learning-management-system/stm-lms-templates/stm-lms-certificates-generator.php

    $_option_name = '_cert_date_' . str_replace ( '', '_',$username) . '_' . str_replace ( '', '_', get_the_title ( $course_id ) );
    

    ….With this….
    $_option_name = '_cert_date_' . str_replace ( chr(32), '_',$username) . '_' . str_replace ( chr(32), '_', get_the_title ( $course_id ) );

    …then, add the following code in the file /wp-content/plugins/masterstudy-lms-learning-management-system/stm-lms-templates/lesson/navigation.php

    At line 63~ replace the:
    <?php endif; ?>

    …with the following code….

    <?php endif;
    
    $user = STM_LMS_User::get_current_user('', false, true);
    $username = $user['login'];
    $_option_name = '_cert_date_' . str_replace (chr(32), '_',$username) . '_' . str_replace (chr(32), '_', get_the_title( $post_id ) );
    $_date = get_option( $_option_name );
    if ( empty( $_date ) ) add_option ( $_option_name, date( 'Y-m-d' ), '', 'no' );
    else update_option ( $_option_name, date( 'Y-m-d' ) );
    ?>

    …this addition will save the last date of course completion to database. This is the real date of course completion.

    Try it and let me know.
    😉

    • This reply was modified 4 years ago by sliontos.
    • This reply was modified 4 years ago by sliontos.
    Thread Starter wesley1066

    (@wesley1066)

    Sorry, answer now, thanks for helping me, update my system to a newer version and now it doesn’t take the code you passed anymore. I tried to redo the whole process but this is giving error I’m not getting more with this code

    Hello guys! It helped me a lot!
    I need to put the course load, is it possible?
    Thank you very much!

    Hello, following the code of the post, the following error line appears.
    how can i solve thanks.

    Code error

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Shortcodes certificate’ is closed to new replies.