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)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Administrator Database Config Trigger’ is closed to new replies.