[wp-trac] Re: [WordPress Trac] #5265: current_user_can() can run before wp_get_current_user() is defined

WordPress Trac wp-trac at lists.automattic.com
Sat Oct 27 10:56:43 GMT 2007


#5265: current_user_can() can run before wp_get_current_user() is defined
----------------------------+-----------------------------------------------
 Reporter:  Viper007Bond    |        Owner:  anonymous
     Type:  defect          |       Status:  new      
 Priority:  normal          |    Milestone:  2.3.2    
Component:  Administration  |      Version:  2.3      
 Severity:  blocker         |   Resolution:           
 Keywords:  needs-patch     |  
----------------------------+-----------------------------------------------
Comment (by westi):

 The problem here is you plugin is running code when included.

 That is a bad plan.

 You should run your setup code on the plugins_loaded or init hook like so:

 {{{
 add_action('plugins_loaded', create_function('','global $WPcomAdminBar;
 $WPcomAdminBar = new WPcomAdminBar()'));
 }}}

 This ensures that all the WordPress functions are available before your
 code runs.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5265#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list