Title: register_activation_hook error on oop plugin
Last modified: August 20, 2016

---

# register_activation_hook error on oop plugin

 *  [Kermit524](https://wordpress.org/support/users/kermit524/)
 * (@kermit524)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/register_activation_hook-error-on-oop-plugin/)
 * Hi, I am writing a new plugin based on a none-wordpress class that I have once
   created.
    On my main plugin page I have an install function, that I wish to hook
   to the plugin registration action with register_activation_hook.
 * So inside the class my function name is: ztree_install.
    This is my code:
 *     ```
       if( class_exists( 'Ztree_plugin' ) ) {
       	global $wpdb;
       	$the_ztree = new Ztree_plugin($wpdb);
       	register_activation_hook( __FILE__, array( &$the_ztree, 'ztree_installl' );
       }
       ```
   
 * But at activating the plugin I get an error message:
    “Warning: call_user_func_array():
   First argument is expected to be a valid callback, ‘create_books’ was given in/
   mnt/sites/matomysendbox.com/htdocs/wp-includes/plugin.php on line 405 Parse error:
   syntax error, unexpected ‘;’ in /mnt/sites/matomysendbox.com/htdocs/wp-content/
   plugins/ztree_forum/ztree_forum.php on line 61 “
 * Any idea where do I go wrong?
    Many thanks in advance, Michal

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

 *  [Anne Dorko](https://wordpress.org/support/users/annedorko/)
 * (@annedorko)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/register_activation_hook-error-on-oop-plugin/#post-3006863)
 * Can we see the `ztree_installl` function, and/or the `create_books` function (
   or perhaps where you called it)?
 * Is the function we’re looking at here line 61?
 * Those pieces of information will be helpful to figure out what’s going wrong.
   🙂
 *  Thread Starter [Kermit524](https://wordpress.org/support/users/kermit524/)
 * (@kermit524)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/register_activation_hook-error-on-oop-plugin/#post-3006864)
 * Ai Anne, thanks for your comment!
    The ztree_install function only included one
   line to verify that it was called at all. But eventually it turned out to be 
   a false alarm. The error message was thrown in fact due to a completely different
   issue, that was not handled right in my code. I have sorted that one out – and
   all is working fine! Thanks again, Michal

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

The topic ‘register_activation_hook error on oop plugin’ is closed to new replies.

## Tags

 * [class](https://wordpress.org/support/topic-tag/class/)
 * [oop](https://wordpress.org/support/topic-tag/oop/)
 * [register_activation_hook](https://wordpress.org/support/topic-tag/register_activation_hook/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [Kermit524](https://wordpress.org/support/users/kermit524/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/register_activation_hook-error-on-oop-plugin/#post-3006864)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
