0

I am building a Drupal 7 site.

User can register in my site using Hybridauth or regular registration form.

I want to change the value in the joined date field. Meaning change the date a user joined the site.

How can I do that?

0

Old users: update the users table in your database. It will be far more efficient.

New users: https://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_presave/7 I don't think the date/time are saved in that form, so what you could do is find the UID and update the table using a sql query after the save is done.

| improve this answer | |
  • thanks for the answer. How can I update the database table? through the phpmyadmin UI? can you please guide me a little? – EB84 Mar 23 '14 at 22:55
  • yep! phpmyadmin would work. "update users set created = 'timestampgoeshere'" – jdu Mar 24 '14 at 12:51
0

You have to implement hook_user_presave like

function hook_user_presave(&$edit, $account, $category) { 
    // your condition goes here
    //$edit['created'] =  REQUEST_TIME - mt_rand(0, 100000);
    $edit['created'] = 1364094210; //timestamp that you want to assign
}

If you want to update some specific user joining date Use

// load user object
$existingUser = user_load('USERID');
// update some user property
$existingUser->created = 'TIMESTAMP';
// save existing user
user_save((object) array('uid' => $existingUser->uid), (array) $existingUser);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.