Using WP Functions Within Plugin Classes

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using WP Functions Within Plugin Classes

Mark Harwood-2
Hi Guys,

Wonder if you could help me with a little problem ive stumbled apon, im
writing a new plugin for a Private Messaging System.

Take a look at the code here - http://pastecode.net/?action=viewpost&tag=720

As you can see theres nothing happening apart from running a check to
see if the user is logged in. For some unknown reason
|is_user_logged_in() |refuses to run within the plugin class.

Is there any reason for this? i guess im missing something stupidly simple.

Many Thanks
Mark 'Phunky' Harwood
Founder of EuroCSS.NET
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Using WP Functions Within Plugin Classes

Sam Angove
On 3/9/06, Mark Harwood <[hidden email]> wrote:
>
> For some unknown reason
> |is_user_logged_in() |refuses to run within the plugin class.
>
> Is there any reason for this? i guess im missing something stupidly simple.

is_user_logged_in() is a pluggable function, so your class's
constructor is run before it gets defined.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Using WP Functions Within Plugin Classes

Mark Harwood-2
Right, that makes sense now!

I assume theres a action to allow it to load after all the WordPress
Functions??

Mark

Sam Angove wrote:

>On 3/9/06, Mark Harwood <[hidden email]> wrote:
>  
>
>>For some unknown reason
>>|is_user_logged_in() |refuses to run within the plugin class.
>>
>>Is there any reason for this? i guess im missing something stupidly simple.
>>    
>>
>
>is_user_logged_in() is a pluggable function, so your class's
>constructor is run before it gets defined.
>_______________________________________________
>wp-hackers mailing list
>[hidden email]
>http://lists.automattic.com/mailman/listinfo/wp-hackers
>  
>

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Using WP Functions Within Plugin Classes

Peter Westwood
Mark Harwood wrote:
> Right, that makes sense now!
>
> I assume theres a action to allow it to load after all the WordPress
> Functions??
>
"plugins_loaded" is the first action after all plugins are loaded and
pluggable functions have been loaded so you could hook onto that.

westi


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Using WP Functions Within Plugin Classes

David Chait
In reply to this post by Mark Harwood-2
if I recall, it isn't safe to test user login state until much later.

try:
  add_action('plugins_loaded', 'my_plugin_init_fn');

to kick off anything related to pluggable_functions.php or potentially
needing other plugins loaded for detection.

-d

----- Original Message -----
From: "Mark Harwood" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, March 08, 2006 8:48 AM
Subject: [wp-hackers] Using WP Functions Within Plugin Classes


| Hi Guys,
|
| Wonder if you could help me with a little problem ive stumbled apon, im
| writing a new plugin for a Private Messaging System.
|
| Take a look at the code here -
http://pastecode.net/?action=viewpost&tag=720
|
| As you can see theres nothing happening apart from running a check to
| see if the user is logged in. For some unknown reason
||is_user_logged_in() |refuses to run within the plugin class.
|
| Is there any reason for this? i guess im missing something stupidly
simple.
|
| Many Thanks
| Mark 'Phunky' Harwood
| Founder of EuroCSS.NET
| _______________________________________________
| wp-hackers mailing list
| [hidden email]
| http://lists.automattic.com/mailman/listinfo/wp-hackers
|

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Using WP Functions Within Plugin Classes

David House
In reply to this post by Mark Harwood-2
On 08/03/06, Mark Harwood <[hidden email]> wrote:
> I assume theres a action to allow it to load after all the WordPress
> Functions??

plugins_loaded, as others have stated, will work. However I'd wait
until init, which guarentees you have the $wp, $wp_query and
$wp_rewrite globals available as well.

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers