Title: Function create_function() is deprecated
Last modified: April 2, 2020

---

# Function create_function() is deprecated

 *  [sara etemad](https://wordpress.org/support/users/sara-etemad/)
 * (@sara-etemad)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/)
 * hi dears
    I am updating my website to PHP 7.2 but unfortunately, I have received
   this error in template files:
 * Function create_function() is deprecated
 * How should I correct it? anybody can help me in new version PHP?
 * add_action( ‘widgets_init’, create_function( ”, ‘register_widget( “Opening_Time”);’));
 * thank you very much
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffunction-create_function-is-deprecated-25%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12618328)
 * What theme is this? You should report this to theme developers. They need to 
   put out an update.
 * This should be the workaround.
 *     ```
       my_init_function() {
          register_widget( 'Opening_Time' );
       }
       add_action('widgets_init','my_init_function');
       ```
   
 *  Thread Starter [sara etemad](https://wordpress.org/support/users/sara-etemad/)
 * (@sara-etemad)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12618572)
 * hi dear [@sterndata](https://wordpress.org/support/users/sterndata/)
    thank you
   for your attention. my template is webmarket and unfortunately, i dont have more
   support from that forset company because my template is expired.
 *  Thread Starter [sara etemad](https://wordpress.org/support/users/sara-etemad/)
 * (@sara-etemad)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12618586)
 * is it possible to solve this problem myself (without their helps)?
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12618743)
 * — edited: I forgot who’s topic I was replying on —
 * Sure. You’ve got their code and, since you’re no longer worried about updates,
   go ahead and fix it.
    -  This reply was modified 6 years, 2 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [sara etemad](https://wordpress.org/support/users/sara-etemad/)
 * (@sara-etemad)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12619016)
 * thank you very much dear [@sterndata](https://wordpress.org/support/users/sterndata/)
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12619032)
 * In case you’re wondering why this popped up, see [https://core.trac.wordpress.org/ticket/48255](https://core.trac.wordpress.org/ticket/48255)
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [6 years, 2 months ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12621382)
 * Replace the line with this:
 * `add_action( 'widgets_init', function() { register_widget( "Opening_Time" ); });`
 *  [saraet](https://wordpress.org/support/users/saraet/)
 * (@saraet)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12687371)
 * thank you dear [@otto42](https://wordpress.org/support/users/otto42/)

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

The topic ‘Function create_function() is deprecated’ is closed to new replies.

## Tags

 * [deprecated](https://wordpress.org/support/topic-tag/deprecated/)
 * [PHP 7.2](https://wordpress.org/support/topic-tag/php-7-2/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 4 participants
 * Last reply from: [saraet](https://wordpress.org/support/users/saraet/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/function-create_function-is-deprecated-25/#post-12687371)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
