Posted by sharique on March 18, 2009 at 12:34pm
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.

Comments
Why?
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
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
Sharique Ahmed Farooqui
Ok
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
sorry and thanks.
In all profile related module, your module is the best.
Sharique uddin Ahmed Farooqui
Sharique Ahmed Farooqui
LOL
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
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
Sharique Ahmed Farooqui
Off topic: Code tag in this post breaks styling on homepage
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.