• Resolved yk26

    (@yk26)


    Hello All,

    I have tried searching for the issue for about a day and after complete exhaust want someone to please rescue on this or some pointer to look into. It can be described as follows bullet points:

    1) working on a plugin development and have admin permission and have checked the usermeta entry to be administrator and s:1:”1″ as specified.
    2) Have 4 pages added as under menu item on the side bar under my plugin menu and I am able to access these pages without worrying.
    3) I have some href links on these pages which call other views that are created under my plugin’s file structure. Any attempt to access these pages result in ‘You do not have sufficient permissions to access this page’

    Please suggest if there is any step I missed to perform to access view other than registered menu item views on a plugin.

    Regards
    A badly stuck user ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • Moderator James Huff

    (@macmanx)

    How are you checking for admin privileges in the plugin?

    I used one plugin in the past which checked to see if current_user_can( 'edit_plugins' ) (even though it had nothing to do with editing plugins) to determine if the account was an admin (as only admins can use the file editor). I had actually disabled the file editor, so the plugin never thought I was an admin.

    The plugin should have been using current_user_can( 'manage_options' ) instead.

    Thread Starter yk26

    (@yk26)

    Thanks Macmanx, I will investigate the property and see if this is the issue. However in my wp_capabilities I have modified the default “administration” to whole lot of those that allow many of the activities. I will call this suggested function and check it ‘edit plugin’ is active.
    Regards
    Yk26

    Moderator James Huff

    (@macmanx)

    Very good. If you are developing the plugin, make sure that you are looking for manage_options. Many administrators may turn off certain capabilities/functions, but I don’t think any will turn off their ability to manage settings. ??

    Thread Starter yk26

    (@yk26)

    Hello MacManX, thanks for your directions
    1) I found that the capabilities were set to ‘manage_options’ using current_user_can. The ‘edit_plugins’ was coming false.
    2) I did elevated the capabilities to ‘edit_plugins’ using User->add_cap, and it started showing ‘edit_plugins’ to be true.
    3) The click on the click here on page still showing me “you do not have sufficient per…..”

    The error log in this issue in wordpress is not at all helpful.

    Regards
    YK26

    Moderator James Huff

    (@macmanx)

    Hm, that is very strange.

    Try creating a fresh install of WordPress (don’t replace your existing one, just make a new one in a subdomain or subdirectory), and only install this plugin. Do you have the same trouble on the new blog?

    Thread Starter yk26

    (@yk26)

    Yes it does the same. It feels like more of directory/files access issue. I have no .htaccess file on my dev server. Do the default permissions need to be elevated somehow?

    Regards
    YK26

    Thread Starter yk26

    (@yk26)

    If I create a view as submenu (that gets registered on the side bar) and such view is used as Click me gets loaded from the admin page but if I use link to any other view file, it throws the permission error.

    Moderator James Huff

    (@macmanx)

    No, it’s not a permissions issue.

    If the plugin cannot identify that an administrator is an administrator on a fresh WordPress installation, then it is fundamentally broken and will fail just the same on all WordPress installations.

    Are you developing this plugin yourself?

    Thread Starter yk26

    (@yk26)

    Yes I am developing a custom plugin where in few admin pages are to be displayed. On choice of the selected options, different views should be displayed for admin/monitoring users on the admin area.

    Moderator James Huff

    (@macmanx)

    Yeah, I’m not entirely sure where to go beyond that if you are indeed using manage_options to identify the admin.

    I recommend 2 things:

    1. Pick some of your favorite plugins and dig through their code. Most of what I learned was by digging through other plugins.

    2. Re-post at https://www.ads-software.com/support/forum/hacks#postform so other plugin developers can see this and offer some assistance.

    Thread Starter yk26

    (@yk26)

    Cool thanks for your directions. I know it seems like closed wall to me also. Thanks anyways.

    Regards
    YK26

    Moderator James Huff

    (@macmanx)

    You’re welcome!

    Thread Starter yk26

    (@yk26)

    I have worked around to the issue by adding a view as submenu of a hidden menu. So it will no longer appear in the menu items still will be registered with the word press workflow and works as usual. Strange that there is no mention about such restriction in wordpress.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘You do not have sufficient permissions to access this page’ is closed to new replies.