Jump to content

Feedback on hook script


prooi

Recommended Posts

Hello guys.

 

I would like some feedback on my hook script, to see if it looks just a bit right.

 

So here goes:

 

<?php 

$con = mysql_connect("localhost","username","password");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("databasename", $con);

function add_user_to_group($vars) {
mysql_query("UPDATE tblclients SET groupid = 2
WHERE id = ". $vars['id'] ."");	
}

add_hook("ClientAdd",1,"add_user_to_group");

mysql_close($con);
?>

 

What I would like this script to do, is to add all new clients to a specific usergroup.

 

Regards,

Frederik Nielsen

Edited by prooi
Edited the script a bit
Link to comment
Share on other sites

Okay, so the connect part could be removed.

 

So this script would do it?

 

<?php 

function add_user_to_group($vars) {
mysql_query("UPDATE tblclients SET groupid = 2
WHERE id = ". $vars['id'] ."");	
}

add_hook("ClientAdd",1,"add_user_to_group");

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated