Title: Undefined variable (with fix)
Last modified: August 20, 2016

---

# Undefined variable (with fix)

 *  Resolved [Austin](https://wordpress.org/support/users/austyfrosty/)
 * (@austyfrosty)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/undefined-variable-with-fix/)
 * You have a undefined variable notice in your plugin at line 150.
 * 150:
    `$rules_BY_id = $this->get_sub_array($options['rules'],'role',$current_user-
   >ID);`
 * Were `$current_user` is only getting set if the `$user_id` is null. That function
   should get the global removed and set a top the function.
 *     ```
       if ($user_id == null){
       	get_currentuserinfo();
       	$user_id = $current_user->ID;
       	if ($user_id <= 0)
       		return true;
       }
       ```
   
 * Also note the _uppercase_ **ID** as `id` is deprecated.
 * So the function should look like:
 *     ```
       public function limitUser($user_id = null,$type = null,$use_m = true){
       	global $current_user;
       ```
   
 * [http://wordpress.org/extend/plugins/bainternet-posts-creation-limits/](http://wordpress.org/extend/plugins/bainternet-posts-creation-limits/)

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

 *  Plugin Author [Bainternet](https://wordpress.org/support/users/bainternet/)
 * (@bainternet)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/undefined-variable-with-fix/#post-3551449)
 * How about just replacing `$current_user->ID` with `$user_id` since the only real
   use and declaration `$current_user` is to set `$user_id` of and changing the 
   id to uppercase?
 * seems much simpler to me.
 * thanks.
    will fix soon
 *  Plugin Author [Bainternet](https://wordpress.org/support/users/bainternet/)
 * (@bainternet)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/undefined-variable-with-fix/#post-3551615)
 * Fixed.
 * Thanks again.

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

The topic ‘Undefined variable (with fix)’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/bainternet-posts-creation-limits_ffffff.
   svg)
 * [Bainternet Posts Creation Limits](https://wordpress.org/plugins/bainternet-posts-creation-limits/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bainternet-posts-creation-limits/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/)
 * [Active Topics](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bainternet-posts-creation-limits/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Bainternet](https://wordpress.org/support/users/bainternet/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/undefined-variable-with-fix/#post-3551615)
 * Status: resolved