• Resolved alaneoutlaw

    (@alaneoutlaw)


    We are noticing the plugin seems to be autogenerating WP user logins even for organizational contacts. This is making it possible for an individual to inadvertently log in as an organization and pay for individual memberships, which then gets attached to the organization instead of the individual. We don’t want any organization logins because all org details are being managed through permissioned relationships with individual contacts.

    Is there a way to limit autogenerated WP logins to individual contacts, not organizations?

    • This topic was modified 7 years, 3 months ago by alaneoutlaw.
Viewing 1 replies (of 1 total)
  • Plugin Author Christian Wach

    (@needle)

    @alaneoutlaw Sorry for the delay – school holidays etc.

    I see your conundrum. Some folks want Organisations (and Households) to have WordPress users (as a shared login) but I can see why you don’t.

    I have added a parameter to the “civi_wp_member_sync_auto_create_wp_user” filter so that you can check the kind of CiviCRM Contact for which a WordPress user is about to be created. You can download the latest version at:

    https://github.com/christianwach/civicrm-wp-member-sync

    To use the filter, try something like the following:

    add_filter( 'civi_wp_member_sync_auto_create_wp_user', 'my_check_civicrm_contact_type', 10, 2 );
    
    /**
     * Check what kind of Contact is being synced before creating WordPress user.
     *
     * @param bool $create_user True if user should be created by default
     * @param int $civi_contact_id The numeric ID of the CiviCRM Contact
     * @return bool True if user should be created, false otherwise
     */
    function my_check_civicrm_contact_type( $create_user, $civi_contact_id ) {
    	
    	// do not create user if no CiviCRM
    	if ( ! civi_wp()->initialize() ) return false;
    
    	// get contact data
    	$contact = civicrm_api( 'contact', 'getsingle', array(
    		'version' => 3,
    		'contact_id' => $contact_id,
    	) );
    	
    	// do not create user if we get an error
    	if ( $contact['is_error'] == 1 ) return false;
    
    	// allow only Individuals to be synced
    	if ( $contact['contact_type'] != 'Individual' ) {
    		$create_user = false;
    	}
    
    	return $create_user;
    	
    }
    

    I will update the plugin available here in due course.

Viewing 1 replies (of 1 total)
  • The topic ‘Organizations being assigned autogenerated WP logins’ is closed to new replies.