Title: JavaScript error on role change
Last modified: April 24, 2019

---

# JavaScript error on role change

 *  [RazyRx](https://wordpress.org/support/users/razyrx/)
 * (@razyrx)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-role-change/)
 * Hello,
 * I have empty capability(do not know how it is happens).
    It is generate checkbox
   like this
 *     ```
       <div id="ure_cap_div_" class="ure-cap-div ure-custom ure-all">
       <input type="checkbox" name="" id="" value="" class="ure-cap-cb">
       <label for="" title=""> </label>
       </div>
       ```
   
 * After role change plugin generate JS error
 *     ```
       Uncaught TypeError: Cannot read property 'removeEventListener' of null
           at HTMLInputElement.<anonymous> (ure.js?ver=5.1.1:554)
       ```
   
 * because checkbox do not have ID
 * Regards,
    Oleg

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [boozedog](https://wordpress.org/support/users/boozedog/)
 * (@boozedog)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-role-change/#post-11471585)
 * I’m seeing same problem. Didn’t notice your topic when I made mine … [https://wordpress.org/support/topic/problem-when-switching-roles-in-main-panel/](https://wordpress.org/support/topic/problem-when-switching-roles-in-main-panel/)
 *  Plugin Author [Vladimir Garagulya](https://wordpress.org/support/users/shinephp/)
 * (@shinephp)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-role-change/#post-11472162)
 * Hi,
 * Send a copy of your user roles to support [at-sign] role-editor.com
    To get a
   serialized value of user roles data use this SQL command:
 *     ```
       SELECT * FROM wp_options WHERE option_name='wp_user_roles';
       ```
   
 * Replace ‘wp_’ with your own database prefix.
    I need data from the option_value
   field.
 * I will look at roles data and add special checking for the empty capability to
   exclude similar issues.
 *  Plugin Author [Vladimir Garagulya](https://wordpress.org/support/users/shinephp/)
 * (@shinephp)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-role-change/#post-11472176)
 * Quick fix:
    open user-role-editor/js/ure.js, go to the line 547
 *     ```
       jQuery('.ure-cap-cb').each(function () { // go through all capabilities checkboxes
       ```
   
 * and insert this code after it
 *     ```
       if (this.id.length===0) {
           return;
       }
       ```
   
 * Resulting code should be:
 *     ```
       jQuery('.ure-cap-cb').each(function () { // go through all capabilities checkboxes
           if (this.id.length===0) {
               return;
           }
           jQuery(this).prop('checked', response.caps.hasOwnProperty(this.id) && response.caps[this.id]);
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘JavaScript error on role change’ is closed to new replies.

 * ![](https://ps.w.org/user-role-editor/assets/icon-256x256.jpg?rev=1020390)
 * [User Role Editor](https://wordpress.org/plugins/user-role-editor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-role-editor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-role-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/user-role-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-role-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-role-editor/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Vladimir Garagulya](https://wordpress.org/support/users/shinephp/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-role-change/#post-11472176)
 * Status: not resolved