LLMS_User_Certificate::get_merge_data()
Retrieve merge codes and data.
Return Return
(string[]) Array mapping merge codes to the merge data.
Source Source
File: includes/models/model.llms.user.certificate.php
protected function get_merge_data() { $template_id = $this->get( 'parent' ); $user_id = $this->get_user_id(); $related_id = $this->get( 'related' ); $engagement_id = $this->get( 'engagement' ); $date_format = get_option( 'date_format' ); $user = get_userdata( $user_id ); $codes = array( // Site. '{site_title}' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), '{site_url}' => get_permalink( llms_get_page_id( 'myaccount' ) ), // User. '{user_login}' => $user ? $user->user_login : '', '{first_name}' => $user ? $user->first_name : '', '{last_name}' => $user ? $user->last_name : '', '{email_address}' => $user ? $user->user_email : '', '{student_id}' => $user ? $user_id : '', // Certificate. '{current_date}' => wp_date( $date_format, llms_current_time( 'timestamp' ) ), '{earned_date}' => $this->get_date( 'date', $date_format ), '{certificate_id}' => $this->get( 'id' ), '{sequential_id}' => $this->get_sequential_id(), ); $codes = LLMS_Engagement_Handler::do_deprecated_filter( $codes, array( $template_id, $user_id, $related_id ), 'certificate', 'llms_certificate_merge_codes', 'llms_certificate_merge_data' ); /** * Filters the certificate merge data. * * @since 6.0.0 * * @param array $codes { * Merge codes and data. * * @type string $code The merge code. E.g. {first_name}. * @type int|string|bool $data The merga data to replace the merge code with. E.g. 'Dude'. * } * @param int $user_id WP User ID of the user who earned the certificate. * @param int $template_id WP_Post ID of the certificate template. * @param int $related_id WP Post ID of the post which triggered the certificate to be awarded. */ return apply_filters( 'llms_certificate_merge_data', $codes, $user_id, $template_id, $related_id ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.1.0 | Added {earned_date} merge code. Allowed {current_date} to be mocked. |
6.0.0 | Introduced. |