WordPress.org

Ready to get started?Download WordPress

Forums

register_activation_hook error on oop plugin (3 posts)

  1. Kermit524
    Member
    Posted 1 year ago #

    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

  2. annedorko
    Member
    Posted 1 year ago #

    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. :)

  3. Kermit524
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic