How do I “replace a function via plugins” in WordPress?

You’re on the right track with creating the plugin. All your assumptions are correct.

To avoid errors on activation you’ll want to wrap the functions that you are redefining in function_exists blocks, as on activation those functions will already be defined:

if ( ! function_exists( 'wp_hash_password' ) ) :

function wp_hash_password( $password ) {
    return 'foo';
}

endif;

Put your code in wp-content/plugins/myfirstplugin/myplugin.php make sure the plugin has the file headers so WordPress knows it is a plugin. There is also some helpful information for this on the Writing a plugin page under the heading Standard Plugin information

Then as you already assumed you activate your plugin on the plugins page in the WordPress admin.

Leave a Comment