Support » Fixing WordPress » pluggable.php, functions.php and wp-admin

  • barat

    (@barat)


    I have a big problem.
    I want to override pluggable.php function called wp_authenticate.
    I place my own wp_authenticate in my theme functions.php file.

    When i go to /wp-admin and try to login, i get:

    Fatal error: Cannot redeclare wp_authenticate() (previously declared in C:\wamp\www\oclab3_10_2010\wp-includes\pluggable.php:481) in C:\wamp\www\oclab3_10_2010\wp-content\themes\oclab\functions.php on line 248

    I placed die(‘pluggable’) in pluggable.php and die(‘functions’) in functions.php and I see, that pluggable.php is fired before functions.php
    In this case overriding pluggable.php functions is impossible.
    I don’t want to change anything in core functions, but I need to override wp_authenticate function for custom rules no mather if I login using sidebar or /wp-admin.

    Can someone help me?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter barat

    (@barat)

    noone knows?
    🙁
    It’s wierd that functions, which should be re-writable can’t be used in wp-admin…

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Did you … undeclare the function before re-defining it? Blanking on the correct term right now, sorry.

    I tried to do this today, and was quite surprised that you can ONLY override the pluggable functions via a Plugin and not from a themes functions.php file.

    I don’t want to have to ship a Plugin with my theme just to override a pluggable function! The function in question is the wp_new_user_notification() function. For users of the theme I want to send a custom welcome message when they register.

    @ipstenu I looked around for a PHP function to undeclare but did find anything suitable. Not sure this is possible without using something like runkit_function_remove(), but this is dependent on the PECL package.

    People are using the functions.php file for some pretty advanced things these days, and it is pretty restricting to not be able to override any of the pluggable functions from my theme code. Doesn’t make sense to me.

    This is a very idiotic default settings that I will have to figure out how to override first thing as soon as i’m able to login.. Ridiculous

    After a bit of poking around, found out that this issue was raised in a trac ticket 5 years ago! But was closed as it was deemed functions.php should not try to emulate Plugins.

    You can see the ticket here: http://core.trac.wordpress.org/ticket/2479#no1

    This could do with re-opening, or a new ticket creating, as there is clearly now a common need for themes to do all manner of things from within the functions.php file.

    It seems pretty restrictive to not allow a theme to override pluggable functions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘pluggable.php, functions.php and wp-admin’ is closed to new replies.