Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#57457 closed defect (bug) (invalid)

save_post hook fires on password reset?

Reported by: dudo's profile Dudo Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.1.1
Component: Users Keywords:
Focuses: Cc:

Description

Hello, I've just find out that on password reset, the [save_post]https://developer.wordpress.org/reference/hooks/save_post/ hook is invoked.

Of course, this can be easily fixed if is_admin() is used.
But, still, this should never run on wp-login.php?action=lostpassword

To reproduce, just install this little plugin and then try to do a password reset

<?php
/*
Plugin Name: Test
Plugin URI: url
Description: Just a test
Author: Dario Curvino
Version: 1.0.0
Author URI: http://dariocurvino.it
*/

//Using is_admin() will fix this

//if(is_admin()) {
    add_action('save_post', static function () {
        if (!current_user_can('edit_posts') ) {
            wp_die('Why am I here?');
        }
    });
//}

Change History (2)

#1 @Dudo
2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

I found out why thanks to the help of Luca Stellone in the Italian wp community chat:
save_post was invoked by the plugin I used to send email, when this is disabled, save_post is not called

#2 @SergeyBiryukov
2 years ago

  • Component changed from General to Users
  • Milestone Awaiting Review deleted

Hi there, welcome back to WordPress Trac!

Thanks for the follow-up! Glad you were able to identify the issue.

Note: See TracTickets for help on using tickets.