• Resolved istrate678

    (@istrate678)


    Hi, I’m new so please be patient with me. I noticed yesterday I can no longer log into the admin area of my site, it gives fatal error. The site itself for visitors is still up and working.

    I used phpMyAdmin to disable all plugins and set a standard theme, which worked fine but didn’t change a thing about the login error. I also never received the email I was supposed to get for the error message. After the error message and just going to my publicly visible site I can even see the bar where I could access my dashboard and profile, but when I clock on anything there I get the fatal error again.

    I then enabled debug and got this:

    Fatal error: Uncaught Error: Call to undefined function create_function() in /mnt/web206/c2/26/53922126/htdocs/WordPress_02/wp-config.php:90 Stack trace: #0 /mnt/web206/c2/26/53922126/htdocs/WordPress_02/wp-load.php(50): require_once() #1 /mnt/web206/c2/26/53922126/htdocs/WordPress_02/wp-admin/admin.php(34): require_once(‘…’) #2 /mnt/web206/c2/26/53922126/htdocs/WordPress_02/wp-admin/index.php(10): require_once(‘…’) #3 {main} thrown in /mnt/web206/c2/26/53922126/htdocs/WordPress_02/wp-config.php on line 90

    I have found out already that create_function is something that has to do with stuff that is no longer supported with newer php versions (I use 8.1 now and can only go back to 8.0 which doesn’t fix the problem. It’s possible the problem existed for longer but I had no reason to go into the backend for a while), but I have no idea what to do about it.

    I’m also a total amateur so I’d need possible explications in non-programmer speech, thank you.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Anonymous User

    (@anonymized-20801613)

    ChatGPT:

    It looks like the error is related to the use of the create_function function, which is deprecated in PHP 7.2 and removed in PHP 8.0. To fix this issue, you need to locate and modify the code that uses create_function in your WordPress installation.

    In your case, the error is occurring in the wp-config.php file on line 90. Unfortunately, I can’t directly access your website’s files, but I can guide you on how to fix it.

    1. Access Your WordPress Files: You will need to access your WordPress files. This can be done using an FTP client or through your hosting provider’s file manager.
    2. Edit wp-config.php: Open the wp-config.php file using a text editor. Look for the line that contains the create_function function. It might look something like this:
    create_function('$args', '...');
    

    or

    add_action('some_hook', create_function('$args', '...'));
    

    Replace create_function: Replace the create_function code with an alternative approach using an anonymous function (closure). For example:

    // Old code
    // create_function('$args', '...');
    
    // New code
    add_action('some_hook', function($args) {
        // ...
    });
    
    1. Replace the appropriate part of the code based on your specific usage. If you’re unsure, you can provide the code around line 90 of wp-config.php, and I can help you with the modification.
    2. Save and Upload: Save the changes to the wp-config.php file and upload it back to your server.

    After making these changes, check if the admin login issue persists. If you encounter any difficulties or if the error is in a different file, feel free to provide more details or ask for further assistance.

    Thread Starter istrate678

    (@istrate678)

    Thank you. I tried but it doesn’t work. I’m not sure exactly which parantheses and quotes I need to keep in the syntax, I probably messed it up there so I reverted it back to the original.

    This is what it says:

    if(is_admin()) {
    add_filter(‘filesystem_method’, create_function(‘$a’, ‘return “direct”;’ ));

    Thread Starter istrate678

    (@istrate678)

    I finally found a solution in older posts, leaving this here in case someone else comes across the same issue: The above quoted line is not part of wordpress core, must have been added by a plugin or something else, even if disabling plugins didn’t resolve my issue.

    After making a copy of the wp-config.php as backup, I simply deleted the above mentioned piece of code with the create_function and can now log into my backend again.

    If you actually want to fix the error replace:

    add_filter(‘filesystem_method’, create_function(‘$a’, ‘return “direct”;’ ));

    With: add_filter( ‘filesystem_method’, function( $a ) { return “direct”; } );

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

The topic ‘Fatal error in admin login, undefined function create_function’ is closed to new replies.