Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update civicrm_group_roles.module #518

Open
wants to merge 3 commits into
base: 7.x-master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions modules/civicrm_group_roles/civicrm_group_roles.module
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,23 @@ function civicrm_group_roles_add_groups_oncreate($account, $roles) {
*/
function civicrm_group_roles_form_alter(&$form, &$form_state, $form_id) {
// append this to change user edit submit function
if (($form['#id'] == 'user-profile-form' && isset($form['#user']) && (module_exists('content_profile') ||
isset($form['account']))) || $form['#id'] == 'user-edit-form') {
$uid = $form['#user']->uid;
if (!$uid) {
return;
}
// make sure there is a civicrm record
civicrm_initialize(TRUE);
require_once 'CRM/Core/BAO/UFMatch.php';
$contact_id = CRM_Core_BAO_UFMatch::getContactId($uid);
if (!$contact_id) {
return;
// Form ID isset Check added for situation when CiviCRM form is being referenced in Drupal node add/edit form
if (isset($form['#id'])) {
if (($form['#id'] == 'user-profile-form' && isset($form['#user']) && (module_exists('content_profile') ||
isset($form['account']))) || $form['#id'] == 'user-edit-form') {
$uid = $form['#user']->uid;
if (!$uid) {
return;
}
// make sure there is a civicrm record
civicrm_initialize(TRUE);
require_once 'CRM/Core/BAO/UFMatch.php';
$contact_id = CRM_Core_BAO_UFMatch::getContactId($uid);
if (!$contact_id) {
return;
}
array_unshift($form['#submit'], '_civicrm_group_update');
}
}
}

Expand Down