{"action":"created","issue":{"url":"https://api.github.com/repos/christianwach/civicrm-wp-member-sync/issues/5","labels_url":"https://api.github.com/repos/christianwach/civicrm-wp-member-sync/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/christianwach/civicrm-wp-member-sync/issues/5/comments","events_url":"https://api.github.com/repos/christianwach/civicrm-wp-member-sync/issues/5/events","html_url":"https://github.com/christianwach/civicrm-wp-member-sync/issues/5","id":90637094,"number":5,"title":"Duplicate Contacts","user":{"login":"mecachisenros","id":3038096,"avatar_url":"https://avatars.githubusercontent.com/u/3038096?v=3","gravatar_id":"","url":"https://api.github.com/users/mecachisenros","html_url":"https://github.com/mecachisenros","followers_url":"https://api.github.com/users/mecachisenros/followers","following_url":"https://api.github.com/users/mecachisenros/following{/other_user}","gists_url":"https://api.github.com/users/mecachisenros/gists{/gist_id}","starred_url":"https://api.github.com/users/mecachisenros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mecachisenros/subscriptions","organizations_url":"https://api.github.com/users/mecachisenros/orgs","repos_url":"https://api.github.com/users/mecachisenros/repos","events_url":"https://api.github.com/users/mecachisenros/events{/privacy}","received_events_url":"https://api.github.com/users/mecachisenros/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-24T10:36:04Z","updated_at":"2015-06-24T15:11:06Z","closed_at":"2015-06-24T15:08:55Z","body":"When adding a new Membership to a contact in CiviCRM, the Member-sync plugin creates a new Wordpress user, but instead of synchronizing the Wordpress user with the CiviCRM contact, it creates a duplicate contact in CiviCRM.\r\n\r\nI've tested this with clean Wordpress and Civicrm install with the same result, it seems the issue appears since CiviCRM 4.6.3 and also happens in 4.6.4\r\n\r\n```\r\nJun 24 09:17:29  [info] $Fatal Error Details = Array\r\n(\r\n    [callback] => Array\r\n        (\r\n            [0] => CRM_Core_Error\r\n            [1] => handle\r\n        )\r\n\r\n    [code] => -5\r\n    [message] => DB Error: already exists\r\n    [mode] => 16\r\n    [debug_info] => INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  4 , 'info@test.com' ,  1 )  [nativecode=1062 ** Duplicate entry 'info@test.com-1' for key 'UI_uf_name_domain_id']\r\n    [type] => DB_Error\r\n    [user_info] => INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  4 , 'info@test.com' ,  1 )  [nativecode=1062 ** Duplicate entry 'info@test.com-1' for key 'UI_uf_name_domain_id']\r\n    [to_string] => [db_error: message=\"DB Error: already exists\" code=-5 mode=callback callback=CRM_Core_Error::handle prefix=\"\" info=\"INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  4 , 'info@test.com' ,  1 )  [nativecode=1062 ** Duplicate entry 'info@test.com-1' for key 'UI_uf_name_domain_id']\"]\r\n)\r\n\r\n\r\nJun 24 09:17:29  [info] $backTrace = #0 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(235): CRM_Core_Error::backtrace(\"backTrace\", TRUE)\r\n#1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))\r\n#2 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))\r\n#3 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error(\"DB Error: already exists\", -5, 16, (Array:2), \"INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALU...\")\r\n#4 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-5, 16, (Array:2), \"INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALU...\")\r\n#5 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -5, NULL, NULL, \"INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALU...\", \"DB_Error\", TRUE)\r\n#6 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(899): DB_common->raiseError(-5, NULL, NULL, NULL, \"1062 ** Duplicate entry 'info@test.com-1' for key 'UI_uf_name_domain_id'\")\r\n#7 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()\r\n#8 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery(\"INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALU...\")\r\n#9 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2442): DB_common->query(\"INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALU...\")\r\n#10 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1060): DB_DataObject->_query(\"INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALU...\")\r\n#11 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(450): DB_DataObject->insert()\r\n#12 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm-wp-member-sync/civi-wp-ms-users.php(520): CRM_Core_DAO->save()\r\n#13 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm-wp-member-sync/civi-wp-ms-members.php(251): Civi_WP_Member_Sync_Users->wp_create_user((Array:66))\r\n#14 [internal function](): Civi_WP_Member_Sync_Members->membership_updated(\"create\", \"Membership\", 1, Object(CRM_Member_BAO_Membership))\r\n#15 /var/www/menas.co/public_html/dev/wp-includes/plugin.php(571): call_user_func_array((Array:2), (Array:4))\r\n#16 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Utils/Hook/WordPress.php(130): do_action_ref_array(\"civicrm_post\", (Array:4))\r\n#17 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Utils/Hook.php(306): CRM_Utils_Hook_WordPress->invoke(4, \"create\", \"Membership\", 1, Object(CRM_Member_BAO_Membership), NULL, NULL, \"civicrm_post\")\r\n#18 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Member/BAO/Membership.php(180): CRM_Utils_Hook::post(\"create\", \"Membership\", 1, Object(CRM_Member_BAO_Membership))\r\n#19 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Member/BAO/Membership.php(310): CRM_Member_BAO_Membership::add((Array:17), (Array:1))\r\n#20 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Member/Form/Membership.php(1593): CRM_Member_BAO_Membership::create((Array:17), (Array:1))\r\n#21 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(345): CRM_Member_Form_Membership->postProcess()\r\n#22 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(166): CRM_Core_Form->mainProcess()\r\n#23 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(133): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Member_Form_Membership), \"upload\")\r\n#24 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Member_Form_Membership), \"upload\")\r\n#25 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Member_Form_Membership), \"upload\")\r\n#26 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(353): HTML_QuickForm_Page->handle(\"upload\")\r\n#27 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Member/Page/Tab.php(281): CRM_Core_Controller->run()\r\n#28 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Member/Page/Tab.php(354): CRM_Member_Page_Tab->edit()\r\n#29 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(312): CRM_Member_Page_Tab->run((Array:4), NULL)\r\n#30 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:14))\r\n#31 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:4))\r\n#32 /var/www/menas.co/public_html/dev/wp-content/plugins/civicrm/civicrm.php(1189): CRM_Core_Invoke::invoke((Array:4))\r\n#33 [internal function](): CiviCRM_For_WordPress->invoke(\"\")\r\n#34 /var/www/menas.co/public_html/dev/wp-includes/plugin.php(496): call_user_func_array((Array:2), (Array:1))\r\n#35 /var/www/menas.co/public_html/dev/wp-admin/admin.php(226): do_action(\"toplevel_page_CiviCRM\")\r\n#36 {main}\r\n```"},"comment":{"url":"https://api.github.com/repos/christianwach/civicrm-wp-member-sync/issues/comments/114902046","html_url":"https://github.com/christianwach/civicrm-wp-member-sync/issues/5#issuecomment-114902046","issue_url":"https://api.github.com/repos/christianwach/civicrm-wp-member-sync/issues/5","id":114902046,"user":{"login":"christianwach","id":726936,"avatar_url":"https://avatars.githubusercontent.com/u/726936?v=3","gravatar_id":"","url":"https://api.github.com/users/christianwach","html_url":"https://github.com/christianwach","followers_url":"https://api.github.com/users/christianwach/followers","following_url":"https://api.github.com/users/christianwach/following{/other_user}","gists_url":"https://api.github.com/users/christianwach/gists{/gist_id}","starred_url":"https://api.github.com/users/christianwach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christianwach/subscriptions","organizations_url":"https://api.github.com/users/christianwach/orgs","repos_url":"https://api.github.com/users/christianwach/repos","events_url":"https://api.github.com/users/christianwach/events{/privacy}","received_events_url":"https://api.github.com/users/christianwach/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T15:11:06Z","updated_at":"2015-06-24T15:11:06Z","body":"@mecachisenros As you can see, I've merged the 'newhooks' branch to 'master' with some modifications. Thanks for the report. As I said, if you could open a new issue for inherited memberships, that'd be appreciated."}}