Title: Email code crashed site
Last modified: August 31, 2016

---

# Email code crashed site

 *  Resolved [natalierose](https://wordpress.org/support/users/natalierose/)
 * (@natalierose)
 * [10 years ago](https://wordpress.org/support/topic/email-code-crashed-site/)
 * Hi,
 * I pasted some code in the functions.php file that said it would put in a customers
   name into an email, but instead it has locked me out of being able to access 
   my wp-admin. The code displays on the wp-admin page instead of bringing up the
   login box. This is the code causing the issue:
 * function custom_use_customer_from_address ( $from_email, $obj ) { if ( is_a( 
   $obj, ‘WC_Email_New_Order’ ) ) { $address_details = $obj->object->get_address(‘
   billing’ ); if ( isset( $address_details[’email’] ) && ” != $address_details[’
   email’] ) { $from_email = $address_details[’email’]; } } return $from_email; }
   add_filter( ‘woocommerce_email_from_address’, ‘custom_use_customer_from_address’,
   null, 2 ); function custom_use_customer_from_name ( $from_name, $obj ) { if (
   is_a( $obj, ‘WC_Email_New_Order’ ) ) { $address_details = $obj->object->get_address(‘
   billing’ ); if ( isset( $address_details[‘first_name’] ) && ” != $address_details[‘
   first_name’] ) { $from_name = $address_details[‘first_name’]; } if ( isset( $
   address_details[‘last_name’] ) && ” != $address_details[‘last_name’] ) { $from_name.
   = ‘ ‘ . $address_details[‘last_name’]; } } return $from_name; } add_filter( ‘
   woocommerce_email_from_name’, ‘custom_use_customer_from_name’, null, 2 );
 * Please could this be fixed/looked at, as I would really like to use this for 
   my business.
 * Thanks
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years ago](https://wordpress.org/support/topic/email-code-crashed-site/#post-7430684)
 * Please be aware you’ll be responsible for any custom code you add to your functions
   file – make sure you understand it, and make sure its current.
 * Post the code within backticks (`) in future so its readable.
 * In your case, when you pasted in theme functions, was it wrapped in php tags?
   Without seeing the file I cannot really tell you the mistake.
 *  Thread Starter [natalierose](https://wordpress.org/support/users/natalierose/)
 * (@natalierose)
 * [10 years ago](https://wordpress.org/support/topic/email-code-crashed-site/#post-7430691)
 * This is where I found it and pasted it exactly as it said to: [https://docs.woothemes.com/document/email-faq/#can-i-adjust-my-new-order-emails-to-show-my-customers-name-and-email-address-instead-of-my-own](https://docs.woothemes.com/document/email-faq/#can-i-adjust-my-new-order-emails-to-show-my-customers-name-and-email-address-instead-of-my-own)
 *  Thread Starter [natalierose](https://wordpress.org/support/users/natalierose/)
 * (@natalierose)
 * [10 years ago](https://wordpress.org/support/topic/email-code-crashed-site/#post-7430693)
 * As for seeing the file, not a lot I can do until I can access it from the host
   manager. But I’m hoping once I’m there I can fix the problem.
 * I was advised by a wordpress support rep to let woocommerce know, hence this 
   thread.
 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years ago](https://wordpress.org/support/topic/email-code-crashed-site/#post-7430696)
 * There are no errors in the code itself. Which means you probably just forgot 
   PHP tags, or pasted in the wrong place.
 * If its going in functions.php, if there is not one already, it needs an opening`
   <?php` tag before the code.
 *  Thread Starter [natalierose](https://wordpress.org/support/users/natalierose/)
 * (@natalierose)
 * [10 years ago](https://wordpress.org/support/topic/email-code-crashed-site/#post-7430703)
 * Yes, that’s probably it. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Email code crashed site’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [email](https://wordpress.org/support/topic-tag/email/)
 * [wp-admin](https://wordpress.org/support/topic-tag/wp-admin/)

 * 5 replies
 * 2 participants
 * Last reply from: [natalierose](https://wordpress.org/support/users/natalierose/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/email-code-crashed-site/#post-7430703)
 * Status: resolved