Add params to actions when creating a WordPress User
Overview
The actions in the CRM_Utils_System_WordPress::createUser()
method would be more helpful if they provided params when they fire. They were originally added to allow other code to know merely that CiviCRM was creating a User (and to prevent recursion) but it would also be useful to know the source Contact and the resulting User ID in some cases.
Example use-case
A plugin that acts on a WordPress User when a Contact is added to a Group listens for GroupContact.create
on the civicrm_post
hook. Works just fine when using the CiviCRM back-end and the Contact and User both exist.
Current behaviour
The plugin will fail to act when a new Contact is added to a Group via a Contribution Page with a Profile that is configured to create a WordPress User. This is because the Contact is added to the Group before the WordPress User is created.
Proposed behaviour
Although not an ideal solution to the problem, adding params to the actions in the CRM_Utils_System_WordPress::createUser()
method would allow a plugin like the above to more easily identify the source Contact and the new User. The GroupContacts can then be checked and acted upon once the User has been created.
Comments
PR to follow.