Skip to:
Content

BuddyPress.org

Opened 5 months ago

Closed 5 months ago

#9172 closed defect (bug) (fixed)

bp_user_has_opted_out() should return false if no email address is provided.

Reported by: dcavins's profile dcavins Owned by: dcavins's profile dcavins
Milestone: 14.0.0 Priority: normal
Severity: normal Version: 12.5.0
Component: Emails Keywords: has-patch
Cc:

Description

bp_user_has_opted_out() uses BP_Optout::optout_exists() internally, but if no where parameters are provided, BP_Optout::get() returns every optout, as you might expect.

This is weird behavior for bp_user_has_opted_out(), though (and for optout_exists, truthfully). We prevent this issue in bp_add_optout() by ensuring that the email address parameter is not empty, so we could add a similar check in bp_user_has_opted_out().

Attachments (1)

9172.1.diff (526 bytes) - added by dcavins 5 months ago.
If no email address parrameter is provided, bp_user_has_opted_out() should return false.

Download all attachments as: .zip

Change History (3)

@dcavins
5 months ago

If no email address parrameter is provided, bp_user_has_opted_out() should return false.

This ticket was mentioned in Slack in #buddypress by dcavins. View the logs.


5 months ago

#2 @dcavins
5 months ago

  • Owner set to dcavins
  • Resolution set to fixed
  • Status changed from new to closed

In 13909:

Change bp_user_has_opted_out() behavior.

Our function bp_user_has_opted_out() should return false if no email address is provided.

The underlying issue is that if you pass no where filter arguments to BP_Optout:: optout_exists() (which uses BP_Optout::get()), you get every optout back, which is the wrong answer in this case.

Props emeralive.

Fixes #9172.

Note: See TracTickets for help on using tickets.