Title: Saving snippet throws 404 Error
Last modified: October 19, 2016

---

# Saving snippet throws 404 Error

 *  [leonbax](https://wordpress.org/support/users/leonbax/)
 * (@leonbax)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/saving-snippet-throws-404-error/)
 * Hi,
 * This seems to be related to the content of the snippet, since I am able to save
   some other snippets. I am trying to add first name and last name to my WooCommerce
   registration via code that i found on the web.
 * Simply adding an empty function shell like this works:
 *     ```
       functionwooc_extra_register_fields() {
   
       }
       add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
       ```
   
 * The moment I add something like this in the function I can’t save.
 *     ```
       function wooc_extra_register_fields() {
           ?>
   
           <p class="form-row form-row-first">
           <label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
           <input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
           </p>
   
           <p class="form-row form-row-last">
           <label for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
           <input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
           </p>
   
           <div class="clear"></div>
   
           <p class="form-row form-row-wide">
           <label for="reg_billing_phone"><?php _e( 'Phone', 'woocommerce' ); ?> <span class="required">*</span></label>
           <input type="text" class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php if ( ! empty( $_POST['billing_phone'] ) ) esc_attr_e( $_POST['billing_phone'] ); ?>" />
           </p>
   
           <?php
       }
   
       add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
       ```
   
 * I tried disabling wp-spamshield, YoastSEO, JetPack, and some more but no changes.
   I have seen other people with similar issues on the forum, but no solution. Can
   you help?

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/saving-snippet-throws-404-error/#post-8341216)
 * This is strange. You say that it throws a 404 error – what is the URL when this
   happens?
 *  Thread Starter [leonbax](https://wordpress.org/support/users/leonbax/)
 * (@leonbax)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/saving-snippet-throws-404-error/#post-8344785)
 * Hi! I figured out a little more but no solution yet.
    The URL is this:
 * [http://2mynds.org/wp-admin/admin.php?page=edit-snippet&id=11&result=updated](http://2mynds.org/wp-admin/admin.php?page=edit-snippet&id=11&result=updated)
 * If you need access to the site, let me know. It’s locked behind a maintenance
   screen still, but I can give you access (although I’d prefer not to make the 
   access method public).
 * Anyway, I found that if I remove the $_Post string that it saves. Actually, I
   can just remove the $ sign and there no longer is an error. Does that give you
   any ideas?
 * So this saves:
 *     ```
       function wooc_extra_register_fields() {
   
           <p class="form-row form-row-first">
           <label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
           <input type="text" class="input-text" name="billing_first_name" id="<?php if ( ! empty( _POST['billing_first_name'] ) ) esc_attr_e( _POST['billing_first_name'] ); ?>" />
           </p>
       }
   
       add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
       ```
   
 * and this doesn’t:
 *     ```
       function wooc_extra_register_fields() {
   
           <p class="form-row form-row-first">
           <label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
           <input type="text" class="input-text" name="billing_first_name" id="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
           </p>
       }
   
       add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
       ```
   
 *  Thread Starter [leonbax](https://wordpress.org/support/users/leonbax/)
 * (@leonbax)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/saving-snippet-throws-404-error/#post-8344801)
 * OK, it’s not the dollar sign, it’s the combination of dollar sign and the POST
   command:
    $POST works _POST works $_POS works $_POST throws 404 error
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/saving-snippet-throws-404-error/#post-8539521)
 * Unfortunately, I’m still unable to reproduce this error. I’ve never even encountered
   a 404 page when using or developing this plugin before. I’m sure access to the
   site in question would be very helpful, if you were okay with that. You can contact
   me directly at shea [at] bungeshea [dot] com
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/saving-snippet-throws-404-error/#post-8539609)
 * Additionally, what does this ‘404 error’ actually look like? Is it the 404 page
   on the front-end of your site? Or the WordPress ‘Sorry, you are not allowed to
   access this page.’ error?

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

The topic ‘Saving snippet throws 404 Error’ is closed to new replies.

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

 * 5 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/saving-snippet-throws-404-error/#post-8539609)
 * Status: not a support question