CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • WordPress Installations (Moderators: Kurund Jalmi, Coleman Watts) »
  • User login creates new contact problem
Pages: [1]

Author Topic: User login creates new contact problem  (Read 2390 times)

joumak

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4.1
  • CMS version: WordPress 3.6.1
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
User login creates new contact problem
September 25, 2013, 01:44:11 pm
I have created custom plugin for WordPress. It creates two new roles (Member, Nonmember) during activation and imports contacts from CiviCRM to WordPress. (Contacts are initially imported from CSV files to CiviCRM) Importing contacts to WP seems to work without problems, but when the imported user logins to WordPress, CiviCRM creates new contact entry for the user instead of using existing information. User's email address is same in both systems. I have also checked that custom roles' capabilities are the same as the minimal capabilities, that CiviCRM adds to roles (e.g. Subscriber), when it is activated in WP. I have also manually added permissions for the custom roles in CiviCRM Access Control. I'm bit clueless here. Should this configuration work? If I understood correctly, user synchronizing is done based on email addresses, so why the CiviCRM adds new contact for a user?

krypto

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 5
  • IT guy for @bhahumanists. Running Civi on WP.
    • British Humanist Association
  • CiviCRM version: 4.5.8
  • CMS version: WordPress 4.x
  • MySQL version: 5.5.x
  • PHP version: 5.5.x
Re: User login creates new contact problem
September 25, 2013, 01:54:04 pm
Might be worth checking your dedupe rules. I think just-email is default, but if it's set to check the name too then you'd see that behaviour.

joumak

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4.1
  • CMS version: WordPress 3.6.1
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: User login creates new contact problem
September 26, 2013, 06:23:16 am
Thanks for the suggestion. I checked dedupe rules and they should be ok. Maybe I have broken something. I synchronized users to contacts in Administer / Users and Permissions menu and got following feedback:
"Saved
Synchronize Users to Contacts completed. Checked 25 user records. Found 25 matching contact records. Created 0 new contact records."
Still the operation created 24 new contact records with identical names & email addresses ??? Is there any special capabilities or settings, that I should check in CiviCRM or WP?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: User login creates new contact problem
September 26, 2013, 07:13:27 am

Do you have any other civi plugins activated? Seems like the sync code does not think its creating a record but something is creating a record

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

joumak

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4.1
  • CMS version: WordPress 3.6.1
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: User login creates new contact problem
September 26, 2013, 12:13:06 pm
Mostly the standard set. Components:
  • CiviContribute
  • CiviPledge
  • CiviMember
  • CiviEvent
  • CiviMail
  • CiviReport

Relevant WP plugins:
  • Capability Manager Enhanced
  • CiviCRM :)
  • CiviMember Role Synchronize
  • User Access Manager
  • Own custom plugin
  • Peter's Login Redirect

I reverted to older data without imported contacts. Now the CiviCRM works as expected (no new contacts created unintentionally), so maybe problems have something to do with import. I let the case rest for a while and do some other features, but report back if problem persists.

Thanks,
Jouni

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: User login creates new contact problem
September 26, 2013, 12:27:39 pm

can u disable civimember role synchronize and try again

i'm assuming your own custom plugin does not implement any civicrm hooks or does anything with civi

thx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

joumak

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4.1
  • CMS version: WordPress 3.6.1
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: User login creates new contact problem
October 04, 2013, 06:10:22 am
Quote from: Donald Lobo on September 26, 2013, 12:27:39 pm
can u disable civimember role synchronize and try again
i'm assuming your own custom plugin does not implement any civicrm hooks or does anything with civi
Yes (didn't help) and no. I suspect that reason for the problem is missing UFMatch entry for members, which I inserted to WordPress from CiviCRM. So maybe I should try to add UFMatch records through API to CiviCRM during account creation?

Thanks,
Jouni

joumak

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4.1
  • CMS version: WordPress 3.6.1
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: User login creates new contact problem
November 20, 2013, 07:31:57 am
Yes, the UFMatch was the missing ingredient. Adding user to WP wasn't enough, but it was easy to add UFMatch entry to CiviCRM. Here is the relevant code snippet for adding a CiviCRM user to WordPress:
Code: [Select]
$all_contacts = civicrm_api('Contact', 'GET', array('version' => 3, 'contact_type' => 'Individual'));
foreach ($all_contacts['values'] as $contact) {
            if (!email_exists($contact['email'])) {
                        $id = wp_insert_user(array('user_login' => $contact['email'], 'user_pass' => $pwd, 'user_email' => $contact['email'], 'display_name' => $contact['display_name'], 'first_name' => $contact['first_name'], 'last_name' => $contact['last_name'], 'role' => $current_member ? 'member' : 'nonmember'));
                        $user = get_user_by('id', $id);
                        CRM_Core_BAO_UFMatch::synchronizeUFMatch( $user, $user->id, $user->email, 'WordPress' );
            }
}
N.B. You have to add member and nonmember roles to WordPress by yourself or use existing WordPress roles.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • WordPress Installations (Moderators: Kurund Jalmi, Coleman Watts) »
  • User login creates new contact problem

This forum was archived on 2017-11-26.