I can't find the place where discussions about PHP code samples or HOWTO are taking place (if it exist).

For example, I was looking for an HOWTO create Drupa account from PHP code, I found nothing like an example/HOWTO and I'd like to share the code I wrote...

In the handbook, there are several sections about PHP snippets, but all refering to a specific version of Drupal... nothing more generic.

Any idea ?

Thanks in advance

Christian

Comments

add1sun’s picture

You can put it anywhere under PHP Snippets (http://drupal.org/handbook/customization/php-snippets) that you think is appropriate - top level if doesn't fit in a sub-section (or create a new sub-section). When you create a new child page you can select which versions you have tested this with. The version info is important since Drupal code is not written with backwards compatibility as a priority so I'm not sure that "generic" PHP code discussion in relation to Drupal is relevant.

If I am misunderstanding what kind of code you wish to share, please explain more.

Drupalize.Me, The best Drupal training, available all the time, anywhere!

cquest’s picture

I could not find how explanations on how to populate the user array, that's what I was looking for.

Here is what I wrote :

$user = array(
  'name' => $name,
  'pass' => user_password(8),  // this generates an 8 chars random password
  'mail' => $email,
  'init' => $name,
  'status' => 1);          // activate account

$result = user_save($user); // false if something went wrong, otherwise contains the fully populated user array

If you think it has enough value to be in the handbook, I'll put it there.

Christian