Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.gravityhelp.com/forums/topic/conditional-statement-to-check-game-status-and-week-using-database-in-wordpress
- add_filter('gform_notification_email_28', 'populate_admin_email_via_db', 10, 2);
- function populate_admin_email_via_db($email,$lead) {
- // set the email we're going to return equal to the email that was passed in, in case something fails
- $selected_email = $email;
- // database connection details
- $dbname = 'databasename';
- $dbuser = 'databaseuser';
- $dbpass = 'databasepassword';
- $dbhost = 'databasehost';
- $dbtable = 'customtablename';
- // the hidden accountID value from the form. it was item 4 in the $lead array for my form
- $account = $lead[4];
- // establish the connection
- $link = mysql_connect($dbhost, $dbuser, $dbpass);
- // if connection was established
- if ($link){
- $sql = "SELECT user_email FROM $dbname.$dbtable WHERE user_login='$account' LIMIT 1;";
- $result = mysql_query($sql);
- // deal with the results
- if($result) {
- // the email address will be the one and only record returned
- $returned_record = mysql_fetch_row($result);
- if(!empty($returned_record))
- $selected_email = $returned_record[0];
- }
- // close the connection if it was established
- mysql_close($link);
- }
- return $selected_email;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement