Theme My login, check new user IP
-
Hi How to check IP with theme-my-login plugin ?
I have created theme-my-login-custom.php file and added this code:<?php function tml_register_form( &$template ) { $IP = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; echo '<p><input type="hidden" name="my-field" id="my-field' . $template->the_instance . '" value="' . $IP . '" size="20" />' . "\n"; } add_action( 'tml_register_form', 'tml_register_form' ); function tml_registration_errors( $errors, $user_login ) { global $wpdb; $select_user = "SELECT user_ip FROM v2_users WHERE user_ip = '".mysql_real_escape_string($IP)."' "; $user_ip = $wpdb->get_var(htmlspecialchars($select_user)); if ($_POST['my-field'] == $user_ip){ $errors->add( 'empty_my-field', __( '"You cant have two accounts' ) ); } } add_action( 'registration_errors', 'tml_registration_errors', 10, 2 ); function tml_user_register( $user_id ) { global $wpdb; $IP = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $data = date("Y-m-d H:i:s"); $data_yst = date("Y-m-d", strtotime("+7 day")); $wpdb->update('v2_users', array("user_registered" => $data, "user_demo_date" => $data_yst, "user_ip" => $IP, "user_taller" => '1000'), array('id' => $user_id), array( '%s'), array( '%d' ) ); } add_action( 'tml_new_user_registered', 'tml_user_register' ); ?>
but user will pass with the samwe IP and user can have account as many as he wants
[ Please do not bump, that’s not permitted here. ]
- The topic ‘Theme My login, check new user IP’ is closed to new replies.