default_email = array('email' => 'name@yourdomain.com', 'name' => 'General enquiries'); // Uncomment this and enter your own default email that */ $this->contact_form_fields = array( 'icit_persoanl_para' => array('description' => 'Your contact information', 'type' => 'paragraph'), 'icit_name' => array('description' => 'Name', 'type' => 'text', 'vital' => true), 'icit_surname' => array('description' => 'Surname', 'type' => 'text', 'vital' => false), 'icit_email' => array('description' => 'Email address', 'type' => 'text', 'vital' => true, 'validate' => 'email'), 'icit_text' => array('description' => 'Your message', 'type' => 'textarea'), 'icit_submit_3' => array('description' => 'Send', 'type' => 'submit') ); if (!isset($this->default_email)) $this->default_email = array("email" => get_bloginfo("admin_email"), "name" => "General enquiries"); $this->recipient = $this->whichuser(); // Setup the recipient if (!$_POST['submitted']) { $this->html(); } else { // Check data for errors and setup local copy of the post variable unset($_POST['submit']); unset($this->postresults); unset($this->errors); foreach (array_keys($_POST) as $key) { if (!empty($_POST[$key])) $this->postresults[$key] = stripslashes($_POST[$key]); if ($this->contact_form_fields[$key]['vital'] && empty($this->postresults[$key])) $this->errors[$key] = true; if ($this->contact_form_fields[$key]['validate'] == 'email' && !$this->valid($this->postresults[$key])) $this->errors[$key] = true; } // Send the message an regenerate the HTML using the return value to generate a message or two. $this->html($this->send()); } } function show_user_email_links() { // Message for people who are logged with the ability to crate posts. if (current_user_can('level_1')) { ?>

Contact links for use in posts.

This section is only visible to logged in users with the rights to create/edit posts/pages. The names below are links to contact forms that can be pasted into posts allowing people to contact that user directly via email. The user must have an account with at least 'contributor' privilege and the email address assigned to that account should be valid (obviously). If the email address is changed at any point the links will become invalid.

The reason for doing it this way is so that you may create wordpress user accounts that are not contactable via email. The links generated create a unique id based on the receivers email address to stop people from guessing the links to every user of the site.

Here are the available links:

  1. Default Account (as set in options)
  2. users WHERE 1 = 1;"; foreach ($wpdb->get_results($query) as $user) { $userdata = get_userdata($user->ID); if ($userdata->user_level >= 1) { // Add the custom string to the end of the permalink.?>
  3. display_name; ?>
default_email; if (!empty($_GET['contact_author']) && !empty($_GET['contact_author']) && !empty($_GET['uid'])) { $user = get_userdata($_GET['contact_author']); if (substr(md5($user->user_login),2,8) != $_GET['uid']) { unset($user); } else $return_email = array('email' => $user->user_email, 'name' => $user->display_name); } return($return_email); } function send() { if (count($this->errors) == 0) { // Format the conent of the mail. $email_subject = "[".get_bloginfo('name')."] Message sent from website."; $email_headers = ""; if (!empty($this->contact_form_fields['icit_email'])) $email_headers .= "Reply-To:".$this->postresults['icit_email']."\n"; $email_headers .= "From: ".get_bloginfo('name')."<".get_settings('admin_email').">\n"; $email_headers .= "MIME-Version: 1.0\n"; $email_headers .= "Content-Type: text/plain; charset=".get_option('blog_charset')."; format=flowed \n"; $email_content = "The following information was submitted to '".get_bloginfo('name')."' website on ".date('l dS \of F Y h:i:s A')."\n"; $email_content .= "This mail originated from page ".$_SERVER["HTTP_REFERER"]." and the sender had the following ip address ".$_SERVER["REMOTE_ADDR"]."\n\n"; foreach (array_keys($this->contact_form_fields) as $key) { if ($this->postresults[$key] != '' && !in_array(strtolower($this->contact_form_fields[$key]['type']), array('checkbox', 'radio'))) { $email_content .= $this->contact_form_fields[$key]['description'].":\n\t".$this->postresults[$key]."\n\n"; } elseif (in_array(strtolower($this->contact_form_fields[$key]['type']), array('checkbox', 'radio')) && $this->postresults[$key] == 'on') { $email_content .= $this->contact_form_fields[$key]['description']." = Yes\n"; } } // Send the mail and return. if (@wp_mail($this->recipient['email'],$email_subject,$email_content,$email_headers )) { return(true); } else { $this->errors['mail_server_problem'] = "There were problems with the mail server.\n We will try and fix the problem as soon as we can."; return(false); } } else { return(false); } } function valid($email) { return (eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$", $email)); } function html($success = null) { $this->show_user_email_links(); // This will show the links to the contact forms for users to those who are logged on with > subscriber account. if ($success) { ?>

Message sent successfully

Thank you,
Someone will get back to you as soon as they can.

errors['mail_server_problem'] == '') { ?>

Oops.

Please check any field that is marked in red and try again.

errors['mail_server_problem'] == '') { ?> errors['mail_server_problem']; ?>
contact_form_fields) as $key) { ?>
contact_form_fields[$key]['description'] && in_array(strtolower($this->contact_form_fields[$key]['type']),array('checkbox', 'hidden', 'password', 'radio', 'text','textarea'))) { ?>contact_form_fields[$key]['type'] == 'paragraph') { echo '

'.$this->contact_form_fields[$key]['description'].'

'; } elseif ($this->contact_form_fields[$key]['type'] == 'submit') {?> contact_form_fields[$key]['type']), array('checkbox', 'hidden', 'password', 'radio', 'text')) ) { ?>postresults[$key] && in_array(strtolower($this->contact_form_fields[$key]['type']), array('hidden', 'password', 'text'))) { echo 'value="'.$this->postresults[$key].'" '; } elseif (!empty($this->postresults[$key]) && in_array(strtolower($this->contact_form_fields[$key]['type']), array('checkbox', 'radio'))) { echo 'checked="checked" '; } if ($this->errors[$key] == true) echo 'style="border-color: red;" '; ?> />contact_form_fields[$key]['type']) == 'textarea') { ?>