Call to a member function add_query_var() error when trying to use wpdb (1 post)

  1. badbadcoder2013
    Posted 3 years ago #

    I am writing a plguin that must send e-mails to a specif addressess. List of addressess are stored in the DB. The problem is that I have to use functions from WordPress (to interact with DB and send e-mails) outside of the WordPress. But when I am trying to do this I am getting next error:
    Fatal error: Call to a member function add_query_var() on a non-object in C:\wamp\www\site\wp-includes\rewrite.php on line 47

    The I am tryin to use WordPress functoins:

    class my_class{
        public $current_plugin_url;
        public $table_name;
        public function __construct(){
            if (isset($_POST['si_contact_submitted'])){
                /*define('WP_USE_THEMES', false);
                // if I use  code above I am getting the same error
                define( 'BLOCK_LOAD', true );
                require_once( '../../..//wp-config.php' );
                require_once('../../../wp-includes/wp-db.php' );
                $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by badbadcoder2013
  • This topic is not resolved
  • WordPress version: 3.5.1