Title: Used Function create_function() is deprecated
Last modified: August 23, 2019

---

# Used Function create_function() is deprecated

 *  Resolved [RalphGL](https://wordpress.org/support/users/ralphgl/)
 * (@ralphgl)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/used-function-create_function-is-deprecated/)
 * Deprecated: Function create_function() is deprecated in /var/www/html/wp-content/
   plugins/code-snippets/php/snippet-ops.php(361) : eval()’d code on line 8

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/used-function-create_function-is-deprecated/#post-11860970)
 * This is a problem with your code. You shouldn’t be using `create_function()`,
   instead use [anonymous functions](https://www.php.net/manual/en/functions.anonymous.php).
 * If you find the snippet that uses `create_function()` and post the relevant part
   here, I can show you how to update it.
 *  Thread Starter [RalphGL](https://wordpress.org/support/users/ralphgl/)
 * (@ralphgl)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/used-function-create_function-is-deprecated/#post-11861150)
 * Thank you Shea, and sorry for my topic here. This is NOT a Code Snippet-fault!
   
   The deprecated funktion was used in code i used for sorting the sites:
 * function sort_my_sites($blogs) {
    $f = create_function(‘$a,$b’,’return strcasecmp(
   $a->blogname,$b->blogname);’); uasort($blogs, $f); return $blogs; } add_filter(‘
   get_blogs_of_user’,’sort_my_sites’);
 * Sorry, my php skills are very bad.
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/used-function-create_function-is-deprecated/#post-11861367)
 * Here’s how you could rewrite that to work with newer versions of PHP:
 *     ```
       add_filter( 'get_blogs_of_user', function ( $blogs ) {
   
       	uasort( $blogs, function ( $a, $b ) {
       		return strcasecmp( $a->blogname, $b->blogname );
       	} );
   
       	return $blogs;
       } );
       ```
   
 *  Thread Starter [RalphGL](https://wordpress.org/support/users/ralphgl/)
 * (@ralphgl)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/used-function-create_function-is-deprecated/#post-11865419)
 * thx – your snippet works fine on my multisite now!

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

The topic ‘Used Function create_function() is deprecated’ 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

 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [deprecated](https://wordpress.org/support/topic-tag/deprecated/)
 * [function](https://wordpress.org/support/topic-tag/function/)

 * 4 replies
 * 2 participants
 * Last reply from: [RalphGL](https://wordpress.org/support/users/ralphgl/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/used-function-create_function-is-deprecated/#post-11865419)
 * Status: resolved