Add a new filter to prevent new user notifications. Also prevents some possible errors that can happen when plugin options haven't been set. Thanks to @federicojacobi for the pull request.#536
Conversation
| $this->statuses_to_log = maybe_unserialize( get_option( $this->option_prefix . 'statuses_to_log', array() ) ); | ||
| $this->statuses_to_log = empty( $this->statuses_to_log ) ? [] : $this->statuses_to_log; |
There was a problem hiding this comment.
There are multiple flavors of this issue, but they all come down to this: when the option doesn't exist or is empty then returned value from get_option is an empty string. Then maybe_unserialize thinks this is an ok value and doesn't return the array set as the default.
Then array functions throw fatals. Ex: in_array
| if ( apply_filters( $this->option_prefix . 'send_new_user_notification', true, $user_id, $params ) ) { | ||
| wp_new_user_notification( $user_id, null, 'both' ); | ||
| } |
There was a problem hiding this comment.
It is possible to user the default WP hooks wp_send_new_user_notification_to_admin and wp_send_new_user_notification_to_user but the problem with this is that by the time those hooks run, the developer cannot know where the user came from.
This is particularly bad when doing an "import" of existing contacts into wp ... perhaps you want to import users but not let them know about it.
just for wp code standards, use long declaration for array
I think these are always arrays
more arrays
empty line doesn't seem necessary here
for wp code style, use longhand to declare arrays
What does this Pull Request do?
in_arraycalls fatal out. Let's cast them into arrays to be sure. In some cases,maybe_unserializeis not returning the default array values.