Support » Plugin: User Role Editor » Broken on new versions of WordPress

  • Hi,

    I didn’t check changelog of recent WordPress versions but it seems that hook suffix changed ont “Users” backend page.
    Old : “users_page_users” . (your part) “-user-role-editor”
    New : “admin_page_users” . (your part) “-user-role-editor”

    Result is javascript doesn’t load on “User Role Editor” page, impossible to change role, add new role, etc…
    See “includes/classes/user-role-editor.php” on line 39 – 45 for suffix definitions and line 860 for exploitation.

    Hotfix for recent WP versions is to modify the suffixes on line 39 – 45 from “users” to “admin”.
    Best fix would be to set suffix according WordPress version.

    Yours Faithfully,
    Birmania

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Vladimir Garagulia

    (@shinephp)

    Hi Birmania,

    Let me to not agree with your conclusion. I tested with WordPress 4.6.1. If you trace “User->User Role Editor” (wp-admin/users.php?page=users-user-role-editor.php) page, then $hook_suffix value is built by
    wp-admin/admin.php at line #161:
    if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
    and then
    wp-admin/includes/plugin.php:get_plugin_page_hookname( $plugin_page, $parent_page ) function, where parameters values in my case are:
    $plugin_page = 'user-user-role-editor.php'
    and
    $parent_page = 'users.php'
    so tracing further I see that:
    $parent gets 'users.php' value at line #1671
    and $page_type = 'admin' at the next line. Then we jump to the line #1679, where
    $page_type gets users value this way:
    $page_type = $admin_page_hooks[$parent];
    So we get the hook value as the result of this function execution:
    $page_type . '_page_' . $plugin_name; equal to ‘users_page_users-user-role-editor’.

    And finally URE’s page is fully functional.

    So there is something special for your site environment. I suppose that some plugin may change the default WordPress behaviour in your case or break JavaScript execution. Browser JavaScript console is helpful in the large quant of similar cases. JavaScript error produced by some other plugin may prevent to loading the jQuery library. URE’s JavaScript code stops working as the result.

    Could you try to deactivate all plugins and re-check? Then activate plugins back one by one and isolate the conflicting code?

    Thread Starter Birmania

    (@birmania)

    Hi Vladimir,

    Thanks for yours informations.
    I just checked using those and custom traces : You are right.
    Your plugin is working fine, my problem came from a homemade plugin that was creating ‘users.php’ submenu in the ‘init’ action instead of the ‘admin_menu’ one.
    Result was that user-role-editor was using my custom submenu as parent instead of ‘users.php’ one.

    After changing the action, all is running fine.
    Considering this, I changed my vote about URE 4.29 and WP 4.6.1 compatibility.

    Yours Faithfully,
    Birmania

    Plugin Author Vladimir Garagulia

    (@shinephp)

    Hi Birmania,

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Broken on new versions of WordPress’ is closed to new replies.