开发者

Drupal 7 terms of use and edit profile

I am trying to setup drupal 7 so that was when users signs-in for the first time they are presented with a terms of use (I have tried the terms of use module but it doesn't suit my needs as it only seems to work when the user creates the account and in our instance all accounts are created by the admin), and as is standard the user has to agree t开发者_开发知识库o these terms inorder to use there account.

For the second part of this once the user logs and agrees with the terms they have to be presented with the edit profile form to make necessarily updates.

Does anyone know of anyway to set this up (preferably without alot of development as this project is short on time)??? Any help is greatly appreciated.


You know that user has not logged in yet if their "access" and "login" values are 0. So it should be enough to check them and if they are 0, redirect user to your T&Cs. In theory at least.

The easiest solution (that comes to my mind right now anyway) would be something like this:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login') {
    $form['#submit'][] = 'MYMODULE_user_login_submit';
  }
}

function MYMODULE_user_login_submit($form, &$form_state) {
  $user = user_load($form_state['uid']);
  if ($user->access == 0) {
    $form_state['redirect'] = 'your-terms-and-conditions-form-url';
  }
}
  1. hook into "user_login" form and add own submit function
  2. in own submit function check both mentioned values, and if they equal 0, redirect user to your T&Cs

The thing is that our submit gets called after main user_login_submit(), where (well, not exactly there) "login" value already gets updated - therefore we can check "access" field.

The rest sounds easy enough - page with T&Cs and agree form, redirecting to user profile edit afterwards, easy-peasy...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜