• 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

    • This topic was modified 1 year, 6 months ago by xlordh.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support brianvu-tp

    (@briantp)

    Hi xlordh,

    Thank you for reaching out!

    It seems that the issue you’re experiencing is related to the premium Certificates Add-on for LearnPress. As this involves a premium plugin, the problem you’re encountering falls outside the scope of support we provide on this forum.

    For further assistance, please create a ticket on our official support system, and our team will be happy to help you resolve the issue.

    This forum is dedicated to supporting the LearnPress plugin, but not the premium plugins.

    Thank you for your understanding!

    Best regards,
    Brianvu-tp

    xlordh

    (@xlordh)

    Were you able to get this working? I was using a similar shortcode for years and it just stopped working. Support told me that since it was custom code they could not help me.

    Thanks! Pat

    Same problem here, everything was working and now it just stopped working.

    Reverting back to 4.2.7.3 fixed the issue, but it’s unsustainable. So there is something that happened in update 4.2.7.4 that brakes it.

    • This reply was modified 1 year, 3 months ago by interzone2.

    Temporary fix for it is in learnpress.php file in plugin root folder.

    Change: add_action( ‘init’, array( $this, ‘plugins_loaded’ ), – 10 );
    To: add_action( ‘plugins_loaded’, array( $this, ‘plugins_loaded’ ), – 10 );

    This is line 526 in 4.2.7.4

    ——–

    The Difference Between init and plugins_loaded

    1. plugins_loaded

    • This hook is triggered after all plugins have been loaded but before init.

    • It is often used to initialize plugin functionality or to load plugin-specific classes, functions, and hooks.

    • Plugins generally hook into plugins_loaded when they depend on other plugins being fully loaded or need to set up global functionality.

    2. init

    • This hook is triggered after WordPress has finished loading all active plugins and after plugins_loaded.

    • It’s typically used for registering post types, taxonomies, and other WordPress-specific functionalities that require WordPress core and all plugins to be initialized.

    • This reply was modified 1 year, 3 months ago by interzone2.
    Thread Starter xlordh

    (@xlordh)

    @interzone2 thanks for your reply. Meanwhile i already have add_action( ‘plugins_loaded’, array( $this, ‘plugins_loaded’ ), – 10 ); in my own learnpress.php file. but still the order number is not coming up on the certificate preview. I think the error might be from the table in phpmyadmin.

    @interzone2 @xlordh it doesn’t work in the new update version 4.2.8.5. Everything changed.

    The add_action(‘plugins_loaded, array($this, ‘plugins_loaded’),-10);

    change to:

    add_action( ‘init’, [ $this, ‘lp_main_handle’ ], – 1000 );

    I have no idea how to fix it. Please help. The order number back to 00000000 in this version.

    @interzone2 @xlordh it doesn’t work in the new update version 4.2.8.5. Everything changed.

    The line:

    add_action( ‘init’, array( $this, ‘plugins_loaded’ ), – 10 );

    has change to:

    add_action( ‘init’, [ $this, ‘lp_main_handle’ ], – 1000 );

    by the developer.

    I have no idea how to fix it. Please help. The order number back to 00000000 in this version.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Order Number on Learnpress Certificate with Custom shortcode not showing’ is closed to new replies.