From: Steve Sutton Date: Tue, 7 Aug 2018 18:41:28 +0000 (-0400) Subject: Update contact plugin so @ and . aren't removed from usernames. X-Git-Tag: v1.1.12^2~8 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c0381dbef7f1b71951c4c2b44fea2d2df14adba6;p=WP-Plugins%2Fglm-member-db-contacts.git Update contact plugin so @ and . aren't removed from usernames. Use sanitize_user to clean user name. --- diff --git a/classes/data/dataContacts.php b/classes/data/dataContacts.php index be75079..7eb36e9 100644 --- a/classes/data/dataContacts.php +++ b/classes/data/dataContacts.php @@ -566,7 +566,7 @@ class GlmDataContacts extends GlmDataAbstract // Clean up username for WorkPress (no punctuation other than _ and - if ($username != false) { - $username = preg_replace('/[^a-zA-Z0-9_-]+/', '', $username); + $username = sanitize_user( $username, true ); } $r = array( diff --git a/models/admin/contacts/index.php b/models/admin/contacts/index.php index aec75f0..5eea84b 100644 --- a/models/admin/contacts/index.php +++ b/models/admin/contacts/index.php @@ -243,7 +243,7 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts // Clean up username to be compatible with WordPress if (isset($_REQUEST['username'])) { - $_REQUEST['username'] = preg_replace('/[^a-zA-Z0-9_-]+/', '', $_REQUEST['username']); + $_REQUEST['username'] = sanitize_user( $_REQUEST['username'], true ); } // Check for existing contact in Wordpress and Contacts diff --git a/models/admin/import/contacts.php b/models/admin/import/contacts.php index e45fa7a..608b5c1 100644 --- a/models/admin/import/contacts.php +++ b/models/admin/import/contacts.php @@ -390,7 +390,7 @@ class GlmMembersAdmin_import_contacts extends GlmDataContacts // Get the contact data into standard parameters $oldMemberID = ($c[0]-0); $memberName = trim($c[1]); - $memberLogin = trim($c[2]);//preg_replace('/[^a-zA-Z0-9_-.\\@]+/', '', trim($c[2])); + $memberLogin = trim($c[2]); $memberPasswd = trim($c[3]); $memberContactEmail = trim($c[4]); $contactFname = trim($c[5]); diff --git a/models/admin/management/contacts.php b/models/admin/management/contacts.php index 007c9c4..4189a02 100644 --- a/models/admin/management/contacts.php +++ b/models/admin/management/contacts.php @@ -760,7 +760,7 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts $okToImport = true; // Clean up member login to remove restricted characters - $memberLogin = preg_replace('/[^a-zA-Z0-9_-]+/', '', $c['member_login']); + $memberLogin = sanitize_user( $c['member_login'], true ); if ($memberLogin != $c['member_login']) { // Report that we're stripping illegal characters from the username @@ -859,19 +859,19 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts $this->wpdb->insert( GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'contacts', array( - 'active' => true, + 'active' => true, 'primary_contact' => true, - 'access' => $this->config['access_numb']['NotDisplayedModerated'], - 'fname' => $c['primary_contact_fname'], - 'lname' => $c['primary_contact_lname'], - 'contact_type' => $contactType, - 'contact_role' => $contactRoleNumb, - 'email' => $c['process_email'], - 'username' => preg_replace('/[^a-zA-Z0-9_-]+/', '', $c['member_login']), - 'notes' => 'Imported from old Web site.', - 'create_time' => date('Y-m-d H:i:s', time()), - 'ref_type' => $this->config['ref_type_numb']['Member'], - 'ref_dest' => $memb['id'] + 'access' => $this->config['access_numb']['NotDisplayedModerated'], + 'fname' => $c['primary_contact_fname'], + 'lname' => $c['primary_contact_lname'], + 'contact_type' => $contactType, + 'contact_role' => $contactRoleNumb, + 'email' => $c['process_email'], + 'username' => $memberLogin, + 'notes' => 'Imported from old Web site.', + 'create_time' => date('Y-m-d H:i:s', time()), + 'ref_type' => $this->config['ref_type_numb']['Member'], + 'ref_dest' => $memb['id'] ), array( '%d', @@ -1025,7 +1025,7 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts // Get the contact data into standard parameters $oldMemberID = ($c[0]-0); $memberName = trim($c[1]); - $memberLogin = preg_replace('/[^a-zA-Z0-9_-]+/', '', trim($c[2])); + $memberLogin = sanitize_user( $c[2], true ); $memberPasswd = trim($c[3]); $memberContactEmail = trim($c[4]);