Problem/Motivation

I want to create a drupal admin user, but not map them to a CRM contact.

Steps to reproduce

1. Enable user contact mapping.
2. Add a new drupal user, with a role like Content Editor.
3. The user now exists as a CRM contact.

Proposed resolution

Add new permission to override the default behavior. If the user has this permission, they can change the behavior for an individual user at time of creation.

Title
Override user contact mapping

Machine name
override crm user contact mapping

Remaining tasks

User interface changes

Alter the user add form to change the mapping setting for user about to be created.

API changes

Data model changes

Issue fork crm-3595639

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mortona2k created an issue. See original summary.

bluegeek9’s picture

bdanin’s picture

I think if we had a boolean that said "do not require a contact for this user" (or similar message) that would be useful for our case.

bluegeek9’s picture

Is it the creation of the contact that is the issue?

If there was an existing contact with the same email, or other criteria, that matches the user, would you still want the mapping created?

mortona2k’s picture

In this scenario, we are adding some admin and developer user accounts to drupal, and do not want contact records for them.

We have these options enabled:
Create contact for new users

Now any new user will get a crm contact. We would need to turn these settings off and create the contact/mapping another way, which would lose the other helpful mapping settings like showing contact fields on a combined form.

However we don't really need those (telephone/address) when creating these admin/dev accounts anyway, so maybe we should go another way with this?

bluegeek9’s picture

What permission should the user need to see the checkbox on the add user form, to not create a contact?

mortona2k’s picture

I think we may need a different approach for our project instead of using a global setting like this.

In our case, members can log in and access parts of the site, like news and voting.

Contacts are primarily added when they participate in evaluation events. When they pass the evaluation and become certified, they have the option to become members and would get a user account at that time.

bluegeek9’s picture

This sounds like two features.

  1. Allowing or forbidding contact creating based on the user's role(s). This would be global and affects users migrated and created programmatically as well as from the add user form.
  2. Override Config for the form post request. Configs can be programmatically overridden. We could expose the maping settings on the add user form so the config can be overridden for this one user being created.

    The SMTP project uses config overrides for their test form.

    https://git.drupalcode.org/project/smtp/-/blob/8.x-1.x/src/Form/TestForm...
    https://git.drupalcode.org/project/smtp/-/blob/8.x-1.x/src/Config/SmtpOv...

mortona2k’s picture

Maybe this is too broad of a rule to implement at the root level?

An application developer may want a certain form to save a contact and linked user.

Having an all or nothing rule seems pretty heavy handed.

bluegeek9’s picture

It sounds like option #2 is what you are looking for. The SMTP module is able to send test emails even when it is not the default mail plugin. It uses a programmatic Override. The same can be done for add user form.

bluegeek9’s picture

Use a dedicated CRM permission:

Title
Override user contact mapping

Machine name
override crm user contact mapping

bluegeek9’s picture

Issue summary: View changes
bluegeek9’s picture

Issue summary: View changes

bluegeek9’s picture

Status: Active » Needs work

This is a work in progress. It works, but needs polish.

bluegeek9’s picture

Assigned: Unassigned » bluegeek9
Status: Needs work » Active

bluegeek9 changed the visibility of the branch 1.0.x to hidden.

bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triage issues and adding more context to existing issues.
  • Review the Developer Docs for accuracy and clarity.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.