WordPress.org

Ready to get started?Download WordPress

Forums

User Role Editor
Allow them accesss to this pulgin (code inside) (3 posts)

  1. blogthisnow
    Member
    Posted 1 year ago #

    I have no idea how user roles are references in a plugin but I want this plugin to be accessible if a user has a certain role called create_new_pcu. Here is the code of the plugin that I think matters:

    <?php
    global $wpdb; include("pcu.php"); function PCUinit($cron = true) { global $wpdb; $i96 = file_get_contents(dirname(__FILE__) . '/pcu.sql'); $i96 = str_replace('{plugin}', i40(),$i96); $i96 = str_replace('{prefix}', $wpdb->prefix, $i96);
    $rows=explode(";",$i96); foreach($rows as $row) { $results = $wpdb->query( $row ); } if ($cron) { $time = mktime(0, 0, 0, date('m'), date('d')+1, date('Y')); wp_schedule_event($time, 'daily', 'pcu_daily_cron'); } } function PCUdeactivate() { global $wpdb; wp_clear_scheduled_hook('pcu_daily_cron');   } if (class_exists('PCUPlugin')) { global $PCUPlugin; $PCUPlugin = new PCUPlugin(); }
    if (!function_exists("PCUPlugin_ap")) { function PCUPlugin_ap() { global $PCUPlugin; if (!isset($PCUPlugin)) { return; } if (function_exists ( 'add_options_page' )) { wp_enqueue_style('thickbox');
    wp_enqueue_script('thickbox'); add_menu_page ( 'Comparipress', 'CompariPress', 9, 'pcu_maintain', array ($PCUPlugin, 'printPCUPage' ) ); add_submenu_page ( 'pcu_maintain', 'Maintain PCUs', 'Maintain PCUs', 9, 'pcu_maintain', array ($PCUPlugin, 'printPCUPage' ) ); add_submenu_page ( 'pcu_maintain', 'Create New PCU', 'Create New PCU', 9, 'pcu_create', array ($PCUPlugin, 'printPCUPage' ) ); add_submenu_page ( 'pcu_maintain', 'Refresh Prices', 'Refresh Prices', 9, 'pcu_refresh', array ($PCUPlugin, 'printRefreshPage' ) ); add_submenu_page ( 'pcu_maintain', 'PCU', 'PCU Configuration', 9, 'pcu_settings', array ($PCUPlugin, 'printAdminPage' ) );
    } add_action ( 'load-toplevel_page_pcu_maintain', array($PCUPlugin, 'frameHook')); add_action ( 'load-comparipress_page_pcu_create', array($PCUPlugin, 'frameHook'));
    } }
    register_activation_hook(__FILE__, 'PCUinit'); register_deactivation_hook(__FILE__, 'PCUdeactivate');
    if (isset($PCUPlugin)) { foreach (glob(dirname(__FILE__) . '/feeds/*.php') as $i30) { if (!strstr($i30,"pcu_feed_aw.php") || class_exists('SoapClient')) include_once $i30; }
    add_action('admin_menu', 'PCUPlugin_ap'); add_action('wp_head', array($PCUPlugin, 'addHeaderCode'), 1);
    add_filter('the_content', array($PCUPlugin, 'addContent'),1); add_shortcode('pcu', array($PCUPlugin, 'printPCUShortcode')); add_action('pcu_daily_cron', array($PCUPlugin, 'cron')); add_action('plugins_loaded', array($PCUPlugin, 'cloakingHook')); } function dabPaqaqbqtFVFmkq4zoIvAU($s) { return strrev($s); } function i40(){ $i23 = defined('PLUGINDIR') ? get_option('siteurl') .'/'. PLUGINDIR . '/' : get_option('siteurl') . '/wp-content/plugins/'; $i23 = defined('WP_CONTENT_URL') ? WP_CONTENT_URL.'/plugins/' : $i23; $i23 = defined('WP_PLUGIN_URL') ? WP_PLUGIN_URL .'/' : $i23; $i55 = basename(dirname(__FILE__)); return $i23.$i55; }

    http://wordpress.org/extend/plugins/user-role-editor/

  2. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    User menu for this plugin is defined by this code

    add_menu_page ( 'Comparipress', 'CompariPress', 9, 'pcu_maintain', array ($PCUPlugin, 'printPCUPage' ) );
    add_submenu_page ( 'pcu_maintain', 'Maintain PCUs', 'Maintain PCUs', 9, 'pcu_maintain', array ($PCUPlugin, 'printPCUPage' ) );
    add_submenu_page ( 'pcu_maintain', 'Create New PCU', 'Create New PCU', 9, 'pcu_create', array ($PCUPlugin, 'printPCUPage' ) );
    add_submenu_page ( 'pcu_maintain', 'Refresh Prices', 'Refresh Prices', 9, 'pcu_refresh', array ($PCUPlugin, 'printRefreshPage' ) );
    add_submenu_page ( 'pcu_maintain', 'PCU', 'PCU Configuration', 9, 'pcu_settings', array ($PCUPlugin, 'printAdminPage' ) );

    It uses deprecated user level 9 (level_9) capability to manage menu access. Change it from 9 to 'create_new_pcu' role name to achieve your goal.

  3. blogthisnow
    Member
    Posted 1 year ago #

    Wow, you just taught me something too. Thanks so much.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.