Skip to content

Instantly share code, notes, and snippets.

@luisabarca
Created February 27, 2014 03:14
Show Gist options
  • Save luisabarca/9243710 to your computer and use it in GitHub Desktop.
Save luisabarca/9243710 to your computer and use it in GitHub Desktop.
Get WordPress administrator email from an external PHP script
<?php
// Load WordPress
require_once('../../../../wp-load.php');
$this_form_spam = trim($_POST['this_title']);
if ( empty($this_form_spam) ) {
// Get values from form
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = get_option('admin_email');
$subject = 'Potential Client Lead';
$message = " Name: $name\r\n Phone: $phone \r\n Email: $email \r\n Message: $message";
$from = "FirmFlip";
$headers = "From: $email\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
if(@mail($to, $subject, $message, $headers)) {
header('Location: /thanks/'); // Use header for redirections
} else {
echo 'Error! Please try again.';
}
} else {
// @TODO:
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment