Title: Administrator Database Config Trigger
Last modified: January 15, 2021

---

# Administrator Database Config Trigger

 *  Resolved [bowmanm](https://wordpress.org/support/users/bowmanm/)
 * (@bowmanm)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/administrator-database-config-trigger/)
 * Hello,
 * I am trying to add a trigger to the wp-config that changes the database connection
   if an administrator signs in (user id 1) however, WordPress keeps throwing up
   errors? If this can not be archived is it possible to create a standalone login
   page for the admin to sign into using a different wp-config file?
 * **Fatal error: Uncaught Error: Call to undefined function wp_get_current_user()**
 *     ```
       <?php
       define( 'DB_NAME', '######' );
   
       define( 'DB_USER', '######' );
   
       define( 'DB_PASSWORD', '######' );
   
       define( 'DB_HOST', '######:####' );
   
       define( 'DB_CHARSET', '######' );
   
       define( 'DB_COLLATE', '' );
   
       define( 'AUTH_KEY',         '################################################################' );
       define( 'SECURE_AUTH_KEY',  '################################################################' );
       define( 'LOGGED_IN_KEY',    '################################################################' );
       define( 'NONCE_KEY',        '################################################################' );
       define( 'AUTH_SALT',        '################################################################' );
       define( 'SECURE_AUTH_SALT', '################################################################' );
       define( 'LOGGED_IN_SALT',   '################################################################' );
       define( 'NONCE_SALT',       '################################################################' );
   
       $table_prefix = '1000_0001_';
   
       define( 'DOMAIN_CURRENT_SITE', 'website.com' );
       define( 'PATH_CURRENT_SITE', '/stores/1000-0001/' );
   
       define(	'WP_DEBUG', false );
       define(	'WP_DEBUG_LOG', false );
   
       function get_current_user_id()
       {
           $user = wp_get_current_user();
           return ( isset( $user->ID ) ? (int) $user->ID : 0 );
       }
   
       if (get_current_user_id() == '1')
       {
       	define( 'CUSTOM_USER_TABLE', '1000_0001_users' );
       	define( 'CUSTOM_USER_META_TABLE', '1000_0001_usermeta' );
       }
       else
       {
       	define(	'CUSTOM_USER_TABLE', 'wp_users' );
       	define(	'CUSTOM_USER_META_TABLE', 'wp_usermeta' );
       }
   
       define(	'COOKIE_DOMAIN', 'website.com' ); 
       define(	'COOKIEHASH', md5( 'https://www.website.com' ) );
   
       if ( ! defined( 'ABSPATH' ) ) {
       	define( 'ABSPATH', __DIR__ . '/' );
       }
       require_once ABSPATH . 'wp-settings.php';
       ```
   

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

 *  [George Appiah](https://wordpress.org/support/users/gappiah/)
 * (@gappiah)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/administrator-database-config-trigger/#post-13912118)
 * I’m not a developer… but I don’t think `wp-config.php` might be the best place
   for this.
 * I’m thinking that is too early, WordPress may not be fully “loaded” at this point,
   and the WordPress functions like you’re trying to use may not be available yet
   to be used… hence the error.
 * See this [infographic](https://www.wpbeginner.com/wp-tutorials/how-wordpress-actually-works-behind-the-scenes-infographic/?display=wide).
 * I also don’t entirely understand what you’re trying to accomplish or the essence
   of it. If an admin signs in and is pushed to another database, is that database
   for a different WordPress site or what? And where will the changes that the admin
   make appear?
 *  Thread Starter [bowmanm](https://wordpress.org/support/users/bowmanm/)
 * (@bowmanm)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/administrator-database-config-trigger/#post-13912336)
 * I have found another method which I will post on a separate topic

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

The topic ‘Administrator Database Config Trigger’ is closed to new replies.

## Tags

 * [admin](https://wordpress.org/support/topic-tag/admin/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [trigger](https://wordpress.org/support/topic-tag/trigger/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 2 replies
 * 2 participants
 * Last reply from: [bowmanm](https://wordpress.org/support/users/bowmanm/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/administrator-database-config-trigger/#post-13912336)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
