shadynicnack (@shadynicnack)

Forum Replies Created

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

  • shadynicnack
    Participant

    @shadynicnack

    Here is what I figured so far….

    – I had created a new file wp-custom-config.php
    – Use define define( ‘NEW_HOST’, host name); and other details.
    – And add code for DB connect like below

    $newdb = new wpdb($DB_USER, $DB_PASSWORD, $DB_NAME, $DB_HOST);
    $newdb->show_errors();

    – Included this file in wp-config.php file.

    So the wp-customer-config.php looks like:

    $DB_NAME_EXT = ‘database’;

    /** database username */
    /*define(‘DB_USER_EXT’, ‘username’);*/
    $DB_USER_EXT = ‘username’;

    /** database password */
    /*define(‘DB_PASSWORD_EXT’, ‘password’);*/
    $DB_PASSWORD_EXT = ‘password’;

    /** database hostname */
    /*define(‘DB_HOST_EXT’, ‘host’);*/
    $DB_HOST_EXT = ‘host’;

    global $newdb;
    $newdb = new wpdb($DB_NAME_EXT, $DB_USER_EXT, $DB_PASSWORD_EXT, $DB_HOST_EXT );
    $newdb->show_errors();

    Like I mention before, I have included it or should I say required it in the wp-config.php at the bottom after require_once(ABSPATH . ‘wp-settings.php’) and looks like…

    require_once(ABSPATH . ‘external-config.php’);
    _______________________________________________________

    FIRST QUESTION: – I read that you can use $newdb in any file any where. How would you do that? Can I see examples?

    SECOND QUESTION: I want to use the $newdb for the login page. So instead of using the $wpdb, I want to use $newdb to pick and check username and password. How would I do that? Would I need to make a custom login page or can I go into the code and switched databases around? Whats the best practice?


    shadynicnack
    Participant

    @shadynicnack

    So where do you place the code? Do we make a new file and include it in the wp_config? Do we do each query/set per page or in a function? Is it possible to use an external database connecting to your login?

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