Title: register_activation_hook
Last modified: August 21, 2016

---

# register_activation_hook

 *  Resolved [wassereimer](https://wordpress.org/support/users/wassereimer/)
 * (@wassereimer)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/register_activation_hook-5/)
 * Hi,
 * i´m writing a plugin. But i have a problem with the install routine.
 * When i want to activate the plugin, i get the error “Das Plugin kann nicht aktiviert
   werden, da es einen fatalen Fehler erzeugt.” that means “The plugin cannot be
   activated. It caused a fatal error.”
 * But i see no error message.
    I´ve tried a lot.
 *     ```
       // multiside installation
       function ecp_activate($networkwide) {
       	global $wpdb;
       	if (function_exists('is_multisite') && is_multisite()) {
       		if ($networkwide) {
       			$old_blog = $wpdb->blogid;
       			$blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
       			foreach ($blogids as $blog_id) {
       				switch_to_blog($blog_id);
       				ecp_install();
       			}
       			switch_to_blog($old_blog);
       			return;
       		}
       	}
       // single installation
         ecp_install();
       }
   
       // install function
       function ecp_install(){
       	global $wpdb;
       	$ecp_table = "CREATE TABLE IF NOT******and so on*****
       	$wpdb->query($ecp_table);
       }
   
       register_activation_hook( __FILE__, 'ecp_activate' );
       ```
   
 * Whats wrong?
 * Best regards

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/register_activation_hook-5/#post-4952493)
 * Have you checked the PHP error logs? If you define `WP_DEBUG` as `true` on _wp-
   config.php_, you should be able to see error messages in your browser.
 *  Thread Starter [wassereimer](https://wordpress.org/support/users/wassereimer/)
 * (@wassereimer)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/register_activation_hook-5/#post-4952545)
 * WP_DEBUG is of course set to true. But getting no error messeges…
    The error 
   log does not have informations about this error.
 *  Thread Starter [wassereimer](https://wordpress.org/support/users/wassereimer/)
 * (@wassereimer)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/register_activation_hook-5/#post-4952552)
 * Ok, now i don´t get the error…. But the table is not created until installation…-.-
 *  Thread Starter [wassereimer](https://wordpress.org/support/users/wassereimer/)
 * (@wassereimer)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/register_activation_hook-5/#post-4952598)
 * Found the problem…. -.- There was two mistakes. First i forgot to delete the
 *     ```
       if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
           exit();
       ```
   
 * Code in a included file (This was the fatal error without message) and there 
   was a path related problem to a file…

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

The topic ‘register_activation_hook’ is closed to new replies.

## Tags

 * [fatal error](https://wordpress.org/support/topic-tag/fatal-error/)
 * [register_activation_hook](https://wordpress.org/support/topic-tag/register_activation_hook/)
 * [routine](https://wordpress.org/support/topic-tag/routine/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 2 participants
 * Last reply from: [wassereimer](https://wordpress.org/support/users/wassereimer/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/register_activation_hook-5/#post-4952598)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
