Order Number on Learnpress Certificate with Custom shortcode not showing
-
Good day all.
When am trying to show order number on the Learnpress certificate by using the custom short codes, The codes just shows 0000000000 instead of user order number . Here is the codes i paste in the plugin functions.php
/* 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 = "14/" . 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'] . ']');
}
}
}This is the codes i use in the plugin funtions.php and attached below is what i get on the certificate instead of the Order number. Any help please
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.