• besides using filters, sometimes i need to rewrite a WP function, like if i want the authors listed as <option> instead of

    • . It would be quite easy to get the function and change just that.
    • is there any way to put that function only inside a plugin ? how to unset that function ? is there a better way ? or we *must* rely on filters and hooks ? (i always write filters and hookers ??

      thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • “i always write filters and hookers”

    Hookers, hey? Takes me back … I believe the way it works, at least as of WP 1.5x, is that any function you place in your “myhacks.php” file will effectively override the intrinsic WP function of that same name, provided you have enabled “my hacks” support in WP admin.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    That would be “my-hacks.php” and no, it can’t override existing functions.

    Anything in pluggable-functions.php can be overridden. The rest cannot. Write a new function to do what you want and use that function instead.

    The my-hacks file is a useful place to store your functions in a way that they won’t get lost when you upgrade, but that’s about all it’s useful for.

    “Anything in pluggable-functions.php can be overridden.”

    Thanks for clarifying that for the beginners – it’s an important thing to know and perhaps I should have been more specific.

    “The my-hacks file is a useful place to store your functions in a way that they won’t get lost when you upgrade, but that’s about all it’s useful for.”

    Perhaps a better way of phrasing that is: the my-hacks.php file is an important place to store any additional functions you may want as well as your customised versions of the intrinsic WP functions defined in the file “pluggable-functions.php”.

    I for instance, don’t like the way the wp_login() very kindly (but foolishly) tells you exactly whether you got the username or the password wrong. So I changed it and by having my version of wp_login() in “pluggable-functions.php”, ensures that my version will always be executed instead of the default WP one, irrespective of any future upgrades. Unless of course the intrinsic WP function which performs the login check gets renamed in a future version…

    WordPress version 2.2.1 doesn’t have the file pluggable-functions.php. Instead I see pluggable.php and inside it says, “/* These functions can be replaced via plugins. They are loaded after plugins are loaded. */”.

    So I want to override wp_new_user_notification and I tried creating a plugin to do this, but I don’t have it right because it’s not working. Do I just define the function? Do I add an action?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘the best way to override a Wp function’ is closed to new replies.