creating a user profile module

I'm creating a user profile module, I want to restrict users, so that oner person can submit only one profile.I implemented check in hook_insert, it displays message properly but does not stop user from posting another profile.

function mybio_insert($node) {
   $res = db_result(db_query('select count(*) from {mybio} where uid=%d',$node->uid));
  
   if($res != 0)
  {  
       form_set_error('name','You have already created a profile.');
      return ;//t('You have already created a profile. ');
}else
  {  
   db_query("insert into {mybio} (nid,vid,uid,address,city,state,dateofbirth)
             values(%d, %d, %d, '%s', '%s', '%s', '%s')",
     $node->nid, $node->vid, $node->uid, $node->address, $node->city,$node->state,date($node->dateofbirth));
   }
}

Few more question :
Is there any way by which I can completely remove 'create profile' from create content menu and provide a link in user's account tab.

Also extra fields of new content type created by me are not visible to CCK.

Login to post comments

Why?

Michelle - Wed, 2009-03-18 13:19

Why reinvent the wheel? There's already two profile modules.

Michelle

Michelle

See my Drupal articles and tutorials or come check out the Coulee Region


learning

Sharique - Wed, 2009-03-18 14:10

I'm learning drupal module development and want to understand how drupal works.
Thank you michelle for suggestions. You have developed 2 very good modules. I have used them in few places.

This time I want write from scratch.

Sharique uddin Ahmed Farooqui


Ok

Michelle - Wed, 2009-03-18 18:19

I wasn't actually referring to my modules but... Good luck.

Michelle

Michelle

See my Drupal articles and tutorials or come check out the Coulee Region


sorry and thanks. In all

Sharique - Thu, 2009-03-19 14:08

sorry and thanks.

In all profile related module, your module is the best.

Sharique uddin Ahmed Farooqui


LOL

Michelle - Thu, 2009-03-19 14:47

As I said, I wasn't referring to my modules. I was talking about core profile and content profile.

Michelle

See my Drupal articles and tutorials or come check out the Coulee Region


I'm looking for solution as

Sharique - Thu, 2009-03-19 14:08

I'm looking for solution as code snippet not as module.

I think I found problem. I have implemented hook_insert which called after node_insert, which insert values in node table.

Sharique uddin Ahmed Farooqui


Off topic: Code tag in this post breaks styling on homepage

visualnotion - Thu, 2009-03-19 17:47

Completely off topic, but on the home page, there is an open code tag, probably due to the teaser break that messes up the styling on this groups' home page.