Hook into all password resets in WordPress and get password before hashing?

Use the password_reset hook. function wpse_password_reset( $user, $new_pass ) { //* Do something useful with $new_pass } add_action( ‘password_reset’, ‘wpse_password_reset’, 10, 2 ); Edited to add after the comment: Looks like the reason I can’t use that is that the plugin uses wp_update_user to set the new password. Is there any way I can intercept … Read more

Don’t prepend WordPress base url to image paths

You cannot insert remote file in this manner. <?php wp_insert_attachment( $attachment, $filename, $parent_post_id ); ?> $filename (string) (optional) Location of the file on the server. Use absolute path and not the URI of the file. The file MUST be in the uploads https://codex.wordpress.org/Function_Reference/wp_insert_attachment You should first download it to temp dir. If you wish to … Read more

Why is pre_get_posts hook invoked multiple times?

The pre_get_posts action runs any time posts are queried. This obviously includes the main query for displaying your latest posts or the current page, but it also includes any other time posts are queried. So that would include any use of WP_Query() or get_posts() in a plugin or your templates, any Recent Posts or similar … Read more

Is it possible to disable a theme programmatically?

here is no specialized hook for this. However the hook switch_theme should work for you. /** * Switches current theme to new template and stylesheet names. * * @since unknown * @uses do_action() Calls ‘switch_theme’ action on updated theme display name. * * @param string $template Template name * @param string $stylesheet Stylesheet name. */ … Read more

Security question – Display a General Custom Login Error Message

Add the following to your functions.php file. function my_custom_error_messages() { global $errors; $err_codes = $errors->get_error_codes(); // Invalid username. if ( in_array( ‘invalid_username’, $err_codes ) ) { $error=”<strong>ERROR</strong>: Custom Message Here”; } // Incorrect password. if ( in_array( ‘incorrect_password’, $err_codes ) ) { $error=”<strong>ERROR</strong>: Another Custom Message Here”; } return $error; } add_filter( ‘login_errors’, ‘my_custom_error_messages’); You … Read more