私はDrupalサイトにCiviCRMをインストールして以来、私はもはやユーザーを救うことができません。
申し訳ありませんが、エラーが発生したため、現時点ではご要望を満たすことができません。これが発生したときに実行していた操作の詳細については、管理者またはサービスプロバイダに問い合わせることをお勧めします。リクエストされたウェブページを読み込むことができません。このページでは、ブラウザの設定でCookieを有効にする必要があります。この設定をチェックし、Cookieを有効にしてください(有効になっていない場合)。その後、もう一度試してください。このエラーが解決しない場合は、サイト管理者に問い合わせてください。
サイト管理者:このエラーは、ユーザーが、設定したベースURL以外のドメインまたはURLを使用してこのページにアクセスしていることを示している可能性があります。例:ベースURLは
http://example.org ですが、一部のユーザーは http://www.example.org または http://myotherexample.org 。
エラーの種類:有効なセッションキーが見つかりませんでした。
CiviのCiviリソースURLは正しいです。 フォームを使用してユーザーを作成すると発生します。
Drupal:8.4.0
CiviCRM:4.7.28
Edit: Because the original website was already
built in Drupal 8 and it relies on some
Drupal 8 features it will not be possible to
switch to Drupal 7.
Same accepted answer: https://stackoverflow.com/a/51280077/4329215
カスタムフォームを作成する場合、Civiは新しいDrupalユーザーを作成するためのフィールドが必要です。
1: Go to Civi profiles (/civicrm/admin/uf/group?reset=1) and
select the desired profile you want to include in the form. I
selected “Your registration form”. Go to settings of the profile
and select “used for => Drupal User
Registration” In Advanced Settings check Account creation
required
2:カスタムフォームで、関数
‘civicrm_form_user_register_form_alter’を実装します。
public function buildForm(array $form, DrupalCoreFormFormStateInterface $form_state) {
$validators = array(
'file_validate_extensions' => array('jpg jpeg png'),
);
$form['uname'] = array(
'#type' => 'textfield',
'#placeholder' => t('Username*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['organisation'] = array(
'#type' => 'textfield',
'#placeholder' => t('Organisation name*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['password'] = array(
'#type' => 'password_confirm',
'#placeholder' => t('Password*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['name'] = array(
'#type' => 'textfield',
'#placeholder' => t('Full Name*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['email'] = array(
'#type' => 'email',
'#placeholder' => t('Email Address*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['street'] = array(
'#type' => 'textfield',
'#placeholder' => t('Street*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['nr'] = array(
'#type' => 'textfield',
'#placeholder' => t('Nr*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['zipcode'] = array(
'#type' => 'textfield',
'#placeholder' => t('Zipcode*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['city'] = array(
'#type' => 'textfield',
'#placeholder' => t('City*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
//This did the trick!
if( function_exists('civicrm_form_user_register_form_alter') ) {
civicrm_form_user_register_form_alter($form,$form_state,'customRegistration');
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Create'),
'#attributes' => array('class' => array('btn', 'btn-cs', 'btn-outline')),
);
$form['#validate'][] = array($this, 'regValidate');
return $form;
}
2:テンプレートで、Civi関数のフィールド名を持つフィールドを追加します。
{{custom_registration_form.civicrm_profile_register}}
/modules/civicrm-drupal/civicrm.moduleに名前があります。
$form['civicrm_profile_register'] = array(
'#markup' => DrupalCoreRenderMarkup::create($html),
'#cache' => [
'max-age' => 0,
],
);
プロファイルのフィールドはカスタムフォームに含まれ、セッションキーの問題はなくなりました。