Title: deprecated php function
Last modified: March 24, 2019

---

# deprecated php function

 *  Resolved [vikiv](https://wordpress.org/support/users/vikiv/)
 * (@vikiv)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/deprecated-php-function-4/)
 * Hi, I’m using this snippet but I discovered that create_function() is deprecated.
   I have not found a solution to fix the problem. Any help will be greatly appreciated!
 * if ( !current_user_can(‘administrator’) ) {
    add_action( ‘init’, create_function(‘
   $a’, “remove_action( ‘init’, ‘wp_version_check’ );” ), 2 ); add_filter( ‘pre_option_update_core’,
   create_function( ‘$a’, “return null;” ) ); }

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/deprecated-php-function-4/#post-11351235)
 * Hey,
 * Yes, `create_function()` has been deprecated and it’s not recommended to use 
   it in newer versions of PHP.
 * Fortunately, PHP 5.3 and later includes a better feature called anonymous functions.
   You can [read more about them on the PHP documentation](https://www.php.net/manual/en/functions.anonymous.php),
   but here’s an example of your code converted to use an anonymous function:
 *     ```
       if ( ! current_user_can( 'administrator' ) ) {
   
       	add_action( 'init', function () {
       		remove_action( 'init', 'wp_version_check' );
       	}, 2 );
   
   
       	add_filter( 'pre_option_update_core', function ( $a ) {
       		return null;
       	} );
       }
       ```
   
 *  Thread Starter [vikiv](https://wordpress.org/support/users/vikiv/)
 * (@vikiv)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/deprecated-php-function-4/#post-11353952)
 * Thanks a Million!

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

The topic ‘deprecated php function’ 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/)

## Tags

 * [create_function](https://wordpress.org/support/topic-tag/create_function/)

 * 2 replies
 * 2 participants
 * Last reply from: [vikiv](https://wordpress.org/support/users/vikiv/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/deprecated-php-function-4/#post-11353952)
 * Status: resolved