• Hi-
    I have a custom plugin that displays on the Super Admin menu but does not display on any of the other roles for which I have it selected. (I’m using multi-site)

    Below is the code for the plugin. Is there something missing that may be causing this problem?
    Thank you-Matt

    <?php

    /*

    Plugin Name: LwG Award Achievement

    Plugin URI: https://www.smartfirm.com

    Description: Allows an Admin to award LearnDash Lesson Completions

    Version: 0.3

    Author: Allen Pooley

    Author URI: https://www.allenpooley.ca

    License: GPLv2

    */

    add_action( ‘admin_menu’, ‘lwg_create_menu’ );

    function lwg_create_menu()

    {

    add_menu_page( ‘Music Works 1’, ‘Music Works 1’, ‘edit_users’, ‘lwg_lesson_complete’, ‘lwg_lesson_complete’);

    }

    function lwg_lesson_complete()

    {

    echo ‘
    <h1>Use the following form to award the lesson to the users:</h1>

    <h2>users:</h2>

    <form action=”” method=”get”>

    <select name=”lesson” id=”lesson”>’;

    // Get the lessons in Course #10 – going to make this dynamic in future

    $lwg_lessons = learndash_get_lesson_list( 28534);

    // Check how many lessons there are

    $lwg_size = sizeof($lwg_lessons);

    // walk the lessons and build a drop-down menu

    for($select=0; $select < $lwg_size; $select++) {

    echo ‘<option value=”‘.$lwg_lessons[$select]->ID.'”>’.$lwg_lessons[$select]->post_name.'</option>’;

    }

    echo ‘</select>’;

    // Built in WP dropdown of users.

    wp_dropdown_users(array(‘selected’ => ‘$user_id’));

    echo ‘<input type=”submit” name=”submit” />

    </form>

    ‘;

    }

    // need to process the awarding after WP is loaded. All other triggers I’ve found were too early and the process failed.

    // if you use BadgeOS method instead of LD you can switch wp_loaded to init.

    add_action(‘wp_loaded’, ‘lwg_process_award’);

    function lwg_process_award() {

    if ( isset( $_GET[‘user’] ) && isset( $_GET[‘lesson’] ) ) {

    $lwg_user = absint($_GET[‘user’]);

    $lwg_lesson = absint($_GET[‘lesson’]);

    // I need to award badges. While I wait on a way to do this dynamically, I’ve had to hardcode the badge IDs

    // https://www.ads-software.com/support/topic/badge-not-awarding-on-learndash-lesson-completion?replies=1

    // Currently the action that checks for completion doesn’t seem to fire when my

    // plugin does the work like it does when a user clicks mark complete

    if ($lwg_lesson == 14) {$lwg_badge = 217;}

    if ($lwg_lesson == 130) {$lwg_badge = 436;}

    if ($lwg_lesson == 18) {$lwg_badge = 437;}

    if ($lwg_lesson == 20) {$lwg_badge = 440;}

    if ($lwg_lesson == 22) {$lwg_badge = 442;}

    if ($lwg_lesson == 24) {$lwg_badge = 444;}

    // “maybe” prevents duplicate badges if they’re not enabled.

    badgeos_maybe_award_achievement_to_user( $lwg_badge , $lwg_user );

    // this is where the magic happens

    learndash_process_mark_complete( $lwg_user , $lwg_lesson );

    // redirect and done.

    wp_redirect( admin_url(‘admin.php?page=lwg_lesson_complete’) );

    exit;

    }

    }

    ?>

    https://www.ads-software.com/plugins/admin-menu-editor/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Janis Elsts

    (@whiteshadow)

    Are you using the free version of Admin Menu Editor or the Pro version? I tested the plugin with the Pro version and everything seemed to work fine – when I enabled the menu for the “Author” role, it showed up as expected.

    Thread Starter matt5834

    (@matt5834)

    Hi Janis-
    I’m using the Pro version.
    Could it have something to do with Multi Site?

    Again, the plugin shows up as a menu option in the Admin Menu Editor settings. I check it. It only shows up on the Super Admin.

    I have User Role Editor Pro set up. I created a user that has every capability and still does not display.

    I’d be happy to contact you with log in info if you could take a look.

    Thank you!
    Matt

    Plugin Author Janis Elsts

    (@whiteshadow)

    Could it have something to do with Multi Site?

    Hmm, I don’t think so. Unless you’ve configured AME to use different menu settings on different sites? In that case, enabling a menu on one site would not make it show up on other sites.

    I’d be happy to contact you with log in info if you could take a look.

    Sure. You can contact me through this page:
    https://w-shadow.com/contact/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Plugin In not Showing in Menu’ is closed to new replies.