Is there a correct, update-proof method for editing default system alerts and verbiage used by the WooCommerce WordPress plugin? (This question probably applies to all WordPress plugins, but WooCommerce is my specific concern right now.)
As a simple example, let's say I want to change "Your password has been reset successfully" to "Your password has been set". The current verbiage is specific to WooCommerce and exists in these two files:
If I hardcode my edit into the second file, it works but risks getting overwritten when updating the plugin. Is there a correct way to do this that's update-proof?
For notices you can use woocommerce_add_notice
filter.
function custom_reset_password_confirmation_message( $message, $notice_type ) {
// Check if it's the password reset notice
if ( 'success' === $notice_type && ! empty( $_GET['password-reset'] ) ) {
// Modify the password reset success message
$message = __( 'Your password has been set.', 'your-text-domain' );
}
return $message;
}
add_filter( 'woocommerce_add_notice', 'custom_reset_password_confirmation_message', 10, 2 );