Title: 501 Errors
Last modified: July 19, 2021

---

# 501 Errors

 *  [aljuk](https://wordpress.org/support/users/aljuk/)
 * (@aljuk)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/501-errors/)
 * Some snippets can’t be edited via the plugin’s editor.
    Any attempt generates
   a 501 Error page. But if I paste the edited snippet directly into its database
   field with PHPMyAdmin, it works fine.
    -  This topic was modified 4 years, 10 months ago by [aljuk](https://wordpress.org/support/users/aljuk/).

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/501-errors/#post-14675994)
 * Are you able to provide an example of one of these snippets?
 *  Thread Starter [aljuk](https://wordpress.org/support/users/aljuk/)
 * (@aljuk)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/501-errors/#post-14676088)
 * Sure. The complete snippet is really long, so I’ll just include a bit of it and
   describe the scenario that triggers the error. The snippet creates meta boxes(
   using CMB2) which is something I’ve been doing with Code Snippets for a long 
   time, and here is a bit of it, creating a dropdown of options to set some post
   meta data …
 *     ```
       add_action( 'cmb2_admin_init', 'register_metabox' );
       function register_metabox() {
       	$meta_boxes_1->add_field( array(
       		'name'       => esc_html__( 'Languages', 'admin-cmb' ),
       		'desc'       => esc_html__( '(tick all that apply)', 'admin-cmb' ),
       		'id'         => 'agent_languages',
       		'type'       => 'multicheck',
       		'options' => array(
       			'cn' => esc_html__('Chinese','admin-cmb'),
       			'de' => esc_html__('German','admin-cmb'),
       			'en' => esc_html__('English','admin-cmb'),
       			'es' => esc_html__('Spanish','admin-cmb'),
       		),
       	) );
       }
       ```
   
 * To add another option (ie. in this case another language choice), I copy one 
   that exists, hit the return key to create an empty line, paste it in, change 
   it as necessary, and click save. This is what started throwing 501 errors on 
   me today, as soon as I tried to save. If I copy the whole snippet, paste it into
   a stand-alone code editor, edit it, then copy and paste the whole snippet back
   into Code Snippets, 501 again. If instead I paste it straight to the Snippets
   field in the database, it accepts it and everything’s normal.
 * At one stage I had the order of two of the options wrong, and wanted to swap 
   them around. It wouldn’t save it, whether I copied just the bit of code and made
   a new line to paste it into, or copy/pasted the whole line.
 * I kept an eye on the browser console, but nothing was evident.
    -  This reply was modified 4 years, 10 months ago by [aljuk](https://wordpress.org/support/users/aljuk/).
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/501-errors/#post-14757189)
 * I’m not really sure what the issue is here. I can’t see anything wrong with the
   code you’ve posted, and it saved and activates fine when I try it out.
 * If I had to guess, I’d say that the problem is the use of what I imagine to be
   a pretty common function name, `register_metabox`. If you have not yet, I would
   recommend rewriting this to use an anonymous function and then trying it out:
 *     ```
       add_action( 'cmb2_admin_init', function () {
       	$meta_boxes_1->add_field( array(
       		'name'       => esc_html__( 'Languages', 'admin-cmb' ),
       		'desc'       => esc_html__( '(tick all that apply)', 'admin-cmb' ),
       		'id'         => 'agent_languages',
       		'type'       => 'multicheck',
       		'options' => array(
       			'cn' => esc_html__('Chinese','admin-cmb'),
       			'de' => esc_html__('German','admin-cmb'),
       			'en' => esc_html__('English','admin-cmb'),
       			'es' => esc_html__('Spanish','admin-cmb'),
       		),
       	) );
       } );
       ```
   
 *  Thread Starter [aljuk](https://wordpress.org/support/users/aljuk/)
 * (@aljuk)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/501-errors/#post-14757341)
 * “I’m not really sure what the issue is here”
 * The issue is that the snippet can’t be edited or changed in the editor, and attempting
   to do so, or to make any changes in the editor at all (even like creating a new
   line), causes a 501 when I attempt to save.
 * I don’t think it has anything to do with the content of the snippet per se.
 * When I copy and save the snippet straight into its database field via phpmyadmin,
   everything’s fine.
 * I can only imagine perhaps some issue with text encoding or length (it’s a long
   snippet) or something of that nature. Maybe I’m somehow triggering an edge-case
   of some sort.
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/501-errors/#post-14757387)
 * By “I’m not really sure what the issue is here” I meant that I am unsure what’s
   causing the problem, not that I doubt there is one.
 * It’s difficult to give advice when I’m not sure how to investigate this. If it
   is a DB encoding problem, then something to try is exporting all snippets, removing
   the database table, and then importing them.

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

The topic ‘501 Errors’ 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: [4 years, 10 months ago](https://wordpress.org/support/topic/501-errors/#post-14757387)
 * Status: not a support question