[ad_1]
This is the code 🙂
/* EWS Change - Custom Shortcode */
function lporderid_function() {
global $wpdb;
$userid = get_current_user_id();
$courseid = get_the_ID();
$sql = "SELECT ref_id FROM wp_learnpress_user_items WHERE user_id = $userid AND item_id = $courseid;";
$refid = $wpdb->get_var($sql);
$ordernumber = "ID Sertifikat: " . str_pad($refid, 10, '0', STR_PAD_LEFT);
return $ordernumber;
}
add_shortcode('lporderid', 'lporderid_function');
/* Adds new shortcode option to cert editor */
add_filter( 'certificates/fields', function($fields) {
$fields[] = array(
'name' => 'shortcode',
'icon' => 'dashicons-smiley',
'title' => __( 'Shortcode', 'learnpress-certificates' )
);
return $fields;
});
if (class_exists('LP_Certificate_Layer')) {
class LP_Certificate_Shortcode_Layer extends LP_Certificate_Layer {
public function apply( $data ) {
$this->options['text'] = do_shortcode('[lporderid course_id="' . $data['course_id'] . ']');
}
}
}
