Custom Plugin In not Showing in Menu
-
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
// 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;
}
}
?>
- The topic ‘Custom Plugin In not Showing in Menu’ is closed to new replies.