Plugin activation problem
-
Hi, I’m having a really frustrating problem. I was developing my plugin (it was active all the time) and then I needed to run a function once on the plugin activation to do some database queries.
I used
register_activation_hook(__FILE__, pt_activate());
as supposed to but WP kept giving me an error stating that pt_activate() is already declared and it cannot be declared again. After some searching in the web I found out that there must be something wrong inside my function.So I removed rehister_activation_hook completely and started deleting lines from my function until i was only left with this:
$pt_parentpages = $wpdb->get_results("SELECT ID, post_title, menu_order FROM $wpdb->posts WHERE post_type = 'page' AND post_parent = '0' ORDER BY menu_order ASC");
And when I try to activate the plugin, it says: Plugin could not be activated because it triggered a fatal error.
ANd it doesn’t say anything more. And it worked fine ( I didn’t get any fatal errors) when the plugin was active while i was developing it and I used the same query.
When I remove the query, WP activates the plugin.
So my question is – what’s wrong? Can I not use $wpdb->query or anything like that at all in my plugin?
- The topic ‘Plugin activation problem’ is closed to new replies.