Code Mod Request
-
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>". wev_temp_user. "</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://www.ads-software.com/plugins/woocommerce-email-verification/
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘Code Mod Request’ is closed to new replies.