You are calling the function too early. The functions.php
is included before current_user_can()
is defined. Never do anything before the hook 'after_setup_theme'
:
Example for the functions.php
add_action( 'after_setup_theme', array( 'WPSE_14041_Base', 'setup' ) );
class WPSE_14041_Base
{
public static function setup()
{
! isset ( $GLOBALS['content_width'] ) and $GLOBALS['content_width'] = 480;
add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'menus' );
add_editor_style();
add_custom_background();
// You may use current_user_can() here. And more. :)
}
}
Related Posts:
- How to fix empty dashboard issue in WordPress?
- Fatal error: Call to undefined function wp() in ../wp-blog-header.php?
- Call to undefined function nocache_headers() [closed]
- The famous WordPress white screen of death
- How do I “fix” a wp-blog-header.php error message?
- Blank/White Screen on Frontend but Accessible backend?
- PHP Fatal error: Cannot call overloaded function for non-object in wp-includes/capabilities.php [closed]
- WordPress White Page with Certain Database
- Memory issues – Fatal error: out of memory – plugins?
- PHP Fatal error: Call to undefined function WP_Filesystem() [closed]
- What does this mean: Object of class WP_Error could not be converted to string
- How to customize the critical error message?
- 500 Error only one one page in the WP admin
- How to make my plugin code die gracefully
- Fatal error…Please help me
- Fatal error after updating to WordPress 5
- Revslider error. Impossible to enter admin dashboard [closed]
- Fatal error after update [closed]
- White screen of death after an auto update of WordPress
- Fatal Error after migrating WordPress site from one host to another
- WordPress problem with fatal error
- After Plugin deinstallation, Login impossible and line50 error
- Need help decrypting error and warning messages
- WordPress crashed during update
- Fatal error: Cannot redeclare get_header_image() (previously declared in [closed]
- locked out of wordpress site ‘warning: require once’
- Can’t access my site due to fatal error [closed]
- White screen after a couple hours?
- My site is not working because of this: Fatal error: Cannot redeclare be_themes_contact_authentication [closed]
- Fatal error: Uncaught Error: Call to undefined function do_action_ref_array() when using wp_signon function
- Allowed memory size exhausted
- Fatal error: Call to undefined function the_archive_title ()
- Fatal error: Call to undefined function reset_mbstring_encoding
- WP_Error with get_category_parents
- Fatal Error Class ‘WP_Widget_Pages’ not found in /home/****/public_html/wp-includes/class-wp-widget-factory.php
- Fatal error in wordpress htdocs
- failed to open stream – wp-includes/blocks/file.php
- WordPress critical error (tried plugin + debug!)
- Not able to access admin console after Installing and activating a plugin
- Fatal error: Uncaught Error: Class ‘WP_REST_Meta_Fields’ not found in
- Uncaught Stripe\Exception\SignatureVerificationException: Unable to extract timestamp and signatures from header
- unable to edit any page of my wordpress website
- How to remove theme that caused WordPress to crash?
- Fatal error: Uncaught Error: Call to undefined function twentynineteen_post_thumbnail()
- Php Fatal error. Blank wordpress admin panel
- Recoverable fatal error: Object of class WP_Error could not be converted to string in /home/xyz/mysite.com/wp-includes/formatting.php on line 3796
- How to fix wordpress white screen of death a cause bad php code?
- Catchable fatal error: Object of class WP_Error could not be converted to string in
- WordPress site suddenly stopped working
- wp search-replace inside site’s directory bring PHP fatal error
- WordPress Fatal Error
- Blank page and 301 redirect
- White Screen of Death error
- WordPress displays 500 error on PHP errors
- WSOD on 4.1.1 after migrating from Bluehost to Dreamhost
- Object of class WP_Post could not be converted to string
- Fatal error: Call to undefined function term_exists()
- Call to undefined function is_blog_installed(), after creating functions.php [closed]
- Parse error: syntax error, unexpected T_FUNCTION on plugins page
- Blank screen at login/logout – tried everything!
- Fatal error: Can’t use method return value in write context
- Fatal error: Call to undefined function request_filesystem_credentials()
- Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 42240 bytes) in /home/dh_w7t9sk/morleywines.com/wp-content/plugins/
- HELP! Fatal Error? I can’t access the Dashboard. How do I regain access? [closed]
- Flamingo’s Fatal error: Allowed memory size of 134217728 … wp-includes/wp-db.php on line 2516 [closed]
- Fatal error: Uncaught Error: Call to undefined function wpcf7
- How to fix Fatal Error in wp-includes/meta.php after upgrade to PHP 8
- Call to undefined function create_function()
- Fatal error: Uncaught Error: Call to undefined method Elementor\Utils::is_ajax() [closed]
- “CRITICAL Object of class WP_Error could not be converted to string” using templates with twig
- WordPress core files – PHP Warning: file_exists(): open_basedir restriction in effect
- How can I fix fatal RevSlider error in dashboard after upgrading to PHP 7? [closed]
- Undefined offset: 0 in > […] /wp-includes/capabilities.php on line 1067
- “Maximum function nesting level of ‘100’ reached” after adding a new filter
- Call to undefined function get_current_screen() on my localhost
- How to fix broken upgrade to 3.1
- Using plugin functionality in external php script not working
- Fatal error: Out of memory
- Fatal error: Uncaught Error: Call to undefined function convert_to_screen()
- Syntax error in a shortcode function
- Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in …\wp-includes\functions.php
- Wp Enviroment problem with included file
- Fatal error on some pages after cancelling WPSTAGING cloning process
- Error with get_price (and others) in self-written plugin to show price
- Upgrading to 4.1 fixed parse error
- After a manual update, themes and plugins that were installed (and still in the directory) are not being seen
- New installation fatal error in 5.9.3 at edit or create entry
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Its my first time trying to create a website , I got an error Please help
- WP website showing blank page after moving from subdomain to main domain
- Fatal error: Class ‘Requests_Utility_CaseInsensitiveDictionary’ not Found in WordPress
- Fatal Error cannot log into wordpress and website disappeared
- pages disable after wordpress update
- Plugin won’t activate, fatal error (widget class not found)
- Fatal error: Call to undefined function get_header() and BuddyPress [closed]
- Catchable fatal error in appcloud free theme by Tokokoo
- Fatal error: Cannot declare class WP_User_Request, because the name is already in use?
- WordPress shows death white screen on multisite
- Fatal Error WordPress Custom Post Type UI + WPML
- WordPress critical error after trying to update to 6.2 – Fatal error: Allowed memory size of 268435456 bytes exhausted