0

I am an Admin of wordpress website and I have created one user with Editor role, I have installed one plugin Pretty Link(https://wordpress.org/plugins/pretty-link/) this plugin shows its menu on Admin page but not on Editors page.

I want to display this menu option on Editor page also, so how to do this? I am using following code for my other menus:

if ( ! function_exists( 'toplevel_admin_menu_pages' ) ) {
function toplevel_admin_menu_pages(){
    if ( !current_user_can('administrator') ) {             // If the user is not the administrator remove and add new menus
        remove_menu_page( 'edit.php' );                     // Posts
        remove_menu_page( 'edit.php?post_type=page' );      // Pages
        remove_menu_page( 'upload.php' );                   // Media
        remove_menu_page( 'tools.php' );                    // Contact From 7
        add_menu_page( 'Home', 'Home', 'edit_posts', 'post.php?post=8&action=edit', '', 'dashicons-admin-home', 25 );
        add_menu_page( 'Life Insurance', 'Life Insurance', 'edit_posts', 'post.php?post=31&action=edit', '', 'dashicons-id-alt', 26 );
        add_menu_page( 'Income Protection', 'Income Protection', 'edit_posts', 'post.php?post=40&action=edit', '', 'dashicons-lock', 27 );
        add_menu_page( 'Superannuation', 'Superannuation', 'edit_posts', 'post.php?post=43&action=edit', '', 'dashicons-search', 28 );
        // add_menu_page( 'Home Loan', 'Home Loan', 'edit_posts', 'post.php?post=47&action=edit', '', 'dashicons-building', 29 );
        add_menu_page( 'About us', 'About Us', 'edit_posts', 'post.php?post=50&action=edit', '', 'dashicons-universal-access-alt', 30 );
        add_menu_page( 'Contact us', 'Contact Us', 'edit_posts', 'post.php?post=55&action=edit', '', 'dashicons-email-alt', 31 );
        add_menu_page( 'Settings', 'Settings', 'edit_posts', 'post.php?post=16&action=edit', '', 'dashicons-admin-generic', 32 );
                add_menu_page( 'Pretty Links', 'Pretty Links', 'edit_posts', 'post.php?post=16&action=edit', '', 'dashicons-admin-generic', 32 );
        }
    }
    add_action( 'admin_menu', 'toplevel_admin_menu_pages' );
}

2 Answers 2

1

Check these links below. This is where the permissions are being set for your pretty link plugin admin menu:

pretty-link/prli-main.php -> line 16 - it's set to administrator you want edit_posts

pretty-link/prli-main.php -> line 160 - it's set to $current_user->user_level >= 8 you want $current_user->user_level >= 7



What are your options?


OPTION 1 - Change the code

  1. Go to this exact link (example should be your site name) and change administrator to edit_posts:

http://example.com/wp-admin/plugin-editor.php?file=pretty-link/prli-main.php&a=te&scrollto=265

  1. Go to this exact link and change if($current_user->user_level >= 8) to if($current_user->user_level >= 7)

http://example.com/wp-admin/plugin-editor.php?file=pretty-link/prli-main.php&a=te&scrollto=2933

  1. Save the changes.


OPTION 2 - Override the code

  1. Add this below to your functions.php to add the admin menus. If you want the dashboard widget as well and they don't have access just do the following for the prli_add_dashboard_widgets function as well.

    remove_action('admin_menu', 'prli_menu');
    add_action('admin_menu', 'prli_menu_new', 99999);
    
    function prli_menu_new()
    {
      global $prli_options, $prlipro_options;
    
      $role = 'edit_posts';
      if(isset($prlipro_options->min_role))
        $role = $prlipro_options->min_role;
    
      $prli_menu_hook = add_menu_page( __('Pretty Link | Manage Pretty Links', 'pretty-link'), __('Pretty Link', 'pretty-link'), $role, 'pretty-link', 'PrliLinksController::route', PRLI_IMAGES_URL.'/pretty-link-small.png' );
      $prli_add_links_menu_hook = add_submenu_page( 'pretty-link', __('Pretty Link | Add New Link', 'pretty-link'), __('Add New Link', 'pretty-link'), $role, 'add-new-pretty-link', 'PrliLinksController::new_link' );
      add_submenu_page('pretty-link', 'Pretty Link | Groups', 'Groups', $role, PRLI_PATH.'/prli-groups.php');
    
      if( isset($prli_options->extended_tracking) and $prli_options->extended_tracking != "count" )
        add_submenu_page('pretty-link', 'Pretty Link | Hits', 'Hits', $role, PRLI_PATH.'/prli-clicks.php');
    
      add_submenu_page('pretty-link', 'Pretty Link | Tools', 'Tools', $role, PRLI_PATH.'/prli-tools.php');
      add_submenu_page('pretty-link', 'Pretty Link | Options', 'Options', $role, PRLI_PATH.'/prli-options.php');
    
      add_action('admin_head-pretty-link/prli-clicks.php', 'prli_reports_admin_header');
      add_action('admin_print_scripts-' . $prli_menu_hook, 'PrliLinksController::load_scripts');
      add_action('admin_print_scripts-' . $prli_add_links_menu_hook, 'PrliLinksController::load_scripts');
      add_action('admin_head-pretty-link/prli-groups.php', 'prli_groups_admin_header');
      add_action('admin_head-pretty-link/prli-options.php', 'prli_options_admin_header');
    
      add_action('admin_print_styles-' . $prli_menu_hook, 'PrliLinksController::load_styles');
      add_action('admin_print_styles-' . $prli_add_links_menu_hook, 'PrliLinksController::load_styles');
    
      add_action('admin_head-' . $prli_menu_hook, 'PrliLinksController::load_dynamic_scripts', 100);
    }
    


Option 3: You can also add these on an individual basis if you don't need to give them access to everything. For example:

add_action( 'admin_menu', 'pretty_links_override_action_edit_posts_role', 99999 );

function pretty_links_override_action_edit_posts_role() {
           $role = 'edit_posts';
           // remove them first
           remove_menu_page( 'pretty-link');
           remove_submenu_page('pretty-link', 'add-new-pretty-link');

           add_menu_page( __('Pretty Link | Manage Pretty Links', 'pretty-link'), __('Pretty Link', 'pretty-link'), $role, 'pretty-link', 'PrliLinksController::route', PRLI_IMAGES_URL.'/pretty-link-small.png' );  
           add_submenu_page( 'pretty-link', __('Pretty Link | Add New Link', 'pretty-link'), __('Add New Link', 'pretty-link'), $role, 'add-new-pretty-link', 'PrliLinksController::new_link' );

}


Option 4: A plugin

Try installing admin menu editor or admin ui customize


Option 5: Premium

Pay for the premium version which has support for this


Option 6: Hack premium options

Hardcode $prlipro_options. While this makes the most sense to me, it's probably not appropriate to add here, since I'd be screwing the plugin author.

0

The free version of this plugin does not appear to support dynamic role assignment. Only users with an access level of 8+ are permitted to manage Pretty Links.

You'll find this coded throughout the plugin:

$current_user->user_level >= 8

If you modify the plugin and change the 8 to a 7 your editors should immediately gain access to the plugin. Based on what I'm seeing in the source code there are just under 20 locations where this may need to be changed but the most important one is in prli-main.php (near line 159).

Additionally, you may be able to reach out to the developer and ask them to improve the role assignment capabilities of the plugin but that might be something that requires an upgrade to the PRO version. The developer would be able to advise you best.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.