• Resolved AITpro

    (@aitpro)


    Hello,

    I was assisting a user with trying to figure out why the email notification links were resulting in 404 errors. I checked your plugin code and noticed that you are hard coding the table names. More importantly you are assuming that someone has not changed their WP Table prefix and are using the default wp_ DB table prefix.

    This is very simple to correct.

    function wev_install(){
    		global $wpdb, $wp_version;
    
    		if($wpdb->get_var("show tables like '".wev_temp_user. "'") != wev_temp_user){
    		$sSql = "CREATE TABLE IF NOT EXISTS <code>&quot;. wev_temp_user. &quot;</code> (";
    		$sSql = $sSql . "<code>user_id</code> INT NOT NULL AUTO_INCREMENT ,";
    		$sSql = $sSql . "<code>user_name</code> TEXT NOT NULL,";
    		$sSql = $sSql . "<code>user_pass</code> TEXT NOT NULL,";
    		$sSql = $sSql . "<code>user_email</code> TEXT NOT NULL,";
    		$sSql = $sSql . "<code>confirm_code</code> TEXT NOT NULL,";
    		$sSql = $sSql . "PRIMARY KEY (<code>user_id</code>)";
    		$sSql = $sSql . ")";
    		$wpdb->query($sSql);
    	}
    	}

    Example of how to use the WordPress DB table prefix object and other things.

    $example_table_name = $wpdb->prefix . "example_table_name";
    
    	if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $example_table_name ) ) != $example_table_name ) {	
    
    	$sql = "CREATE TABLE $example_table_name (
      id bigint(20) NOT NULL AUTO_INCREMENT,
      status VARCHAR(60) DEFAULT '' NOT NULL,
      user_id VARCHAR(60) DEFAULT '' NOT NULL,
      username VARCHAR(60) DEFAULT '' NOT NULL,
      public_name VARCHAR(250) DEFAULT '' NOT NULL,
      email VARCHAR(100) DEFAULT '' NOT NULL,
      role VARCHAR(15) DEFAULT '' NOT NULL,
      human_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
      login_time VARCHAR(10) DEFAULT '' NOT NULL,
      lockout_time VARCHAR(10) DEFAULT '' NOT NULL,
      failed_logins VARCHAR(2) DEFAULT '' NOT NULL,
      ip_address VARCHAR(45) DEFAULT '' NOT NULL,
      hostname VARCHAR(60) DEFAULT '' NOT NULL,
      request_uri VARCHAR(255) DEFAULT '' NOT NULL,
      UNIQUE KEY id (id)
        );";
    
    	require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    	dbDelta($sql);
    	}

    https://wordpress.org/plugins/woocommerce-email-verification/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author subhansanjaya

    (@subhansanjaya)

    Thanks for letting me know, but I’m not sure why I need to use prefix for the custom table as if you check the class file, you will see that I used table prefix for the core tables.

    Thread Starter AITpro

    (@aitpro)

    Well what happens is your DB Tables are never created in the first place. Then these php errors will be seen in the php error log file.

    This particular user’s DB table prefix is: cwkq1hx6b_
    You can see from the php errors that the DB name is limeskittles and the error indicates that the wp_users DB table does not exist because the DB table name is cwkq1hx6b_users since the DB Table prefix was changed/renamed.

    [25-Apr-2014 01:24:53 UTC] WordPress database error Table 'limeskittles.wp_users' doesn't exist for query
    		SELECT *
    		FROM <code>wp_users</code>
    		WHERE <code>ID</code> = 58
    		LIMIT 1
    		 made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, WC_Form_Handler->process_registration, wc_create_new_customer, wp_insert_user, do_action('user_register'), call_user_func_array, WEV_Email_Verification->create_temp_user

    Same issue here. the DB table does not exist and if it did it should be cwkq1hx6b_wev_temp_user and NOT wev_temp_user.

    [28-Apr-2014 05:02:38 UTC] WordPress database error Table 'limeskittles.wev_temp_user' doesn't exist for query INSERT INTOwev_temp_user`
    			(user_name, user_pass, user_email, confirm_code)
    			VALUES('info', '$P$BvxRe/u/HyZUtZ0nsI0mx.XUvMOJVL.', 'info@ait-pro.com', '652be0f93752ea92fa63d999b03d5ee5') made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, WC_Form_Handler->process_registration, wc_create_new_customer, wp_insert_user, do_action('user_register'), call_user_func_array, WEV_Email_Verification->create_temp_user`
    Thread Starter AITpro

    (@aitpro)

    And yes I did see that your class was using the WP DB Table prefix code so you only need to modify the other functions that do not have/include the necessary WP DB Table prefix code.

    Plugin Author subhansanjaya

    (@subhansanjaya)

    I don’t think it is necessary to use prefix for a custom table which is temporary. You probably testing an old version of the plugin or you might change the code.

    Thread Starter AITpro

    (@aitpro)

    I downloaded your most current version. It is no big deal to me and does not matter to me. I will inform the user that he needs to uninstall or recode your plugin if he wants to use it. I was just trying to help you out to save you the endless headaches you are definitely going to have with your plugin. Good luck with that.

    Plugin Author subhansanjaya

    (@subhansanjaya)

    Thanks because I’m getting really good reviews about the plugin and there is a premium version of the plugin. You can have a look, if you like.

    Thread Starter AITpro

    (@aitpro)

    Congratulations! Yep, we do pretty well ourselves with our Pro version. 😉

    your code messed up our site, just because you don’t have bad reviews doesnt mean your code is good. AITpro hit the name on the head, good luck with the problems you will eventually have. i uninstalled your plugin and NOW the problem is gone. 🙂
    you need to sometimes listen to others that have more experience. you cost me a lot of headaches until the problem YOUR PLUGIN was found.

    Thread Starter AITpro

    (@aitpro)

    @kushclean – ouch man. I did not expect you to give this plugin author a 1 star vote (being a plugin author this is a very painful thing). I understand your frustration man, but give subhansanjaya a chance on this one to correct things or work directly with you to figure this out. I think everything just got misinterpreted/distorted here so I’m sure you can work this out. You can change your star ratings/vote once everything is good to go. Thanks.

    Thread Starter AITpro

    (@aitpro)

    I stand corrected and was wrong about needing to add the additional – $wpdb->prefix – object since I misinterpreted what your plugin is doing.

    The source origin of the problem is that the wp better security plugin was installed on this site at one point and it breaks your plugin. See the link below for additional information.

    http://wordpress.org/support/topic/admin-area-impossible-to-create-new-account?replies=18#post-5518161

    found the problem
    here is my new review
    which clearly find me and ithemes DB entry at fault
    not your plugin
    great work
    it does what it says and thats what we wanted

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Code Mod Request’ is closed to new replies.