Changeset 12898 for trunk/src/bp-core/bp-core-functions.php
- Timestamp:
- 04/20/2021 04:02:43 PM (5 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r12893 r12898 4277 4277 return apply_filters( 'bp_get_widget_max_count_limit', 50, $widget_class ); 4278 4278 } 4279 4280 /** 4281 * Add a new BP_Optout. 4282 * 4283 * @since 8.0.0 4284 * 4285 * @param array $args { 4286 * An array of arguments describing the new opt-out. 4287 * @type string $email_address Email address of user who has opted out. 4288 * @type int $user_id Optional. ID of user whose communication 4289 * prompted the user to opt-out. 4290 * @type string $email_type Optional. Name of the email type that 4291 * prompted the user to opt-out. 4292 * @type string $date_modified Optional. Specify a time, else now will be used. 4293 * } 4294 * @return false|int False on failure, ID of new (or existing) opt-out if successful. 4295 */ 4296 function bp_add_optout( $args = array() ) { 4297 $optout = new BP_Optout(); 4298 $r = bp_parse_args( 4299 $args, array( 4300 'email_address' => '', 4301 'user_id' => 0, 4302 'email_type' => '', 4303 'date_modified' => bp_core_current_time(), 4304 ), 4305 'add_optout' 4306 ); 4307 4308 // Opt-outs must have an email address. 4309 if ( empty( $r['email_address'] ) ) { 4310 return false; 4311 } 4312 4313 // Avoid creating duplicate opt-outs. 4314 $optout_id = $optout->optout_exists( 4315 array( 4316 'email_address' => $r['email_address'], 4317 'user_id' => $r['user_id'], 4318 'email_type' => $r['email_type'], 4319 ) 4320 ); 4321 4322 if ( ! $optout_id ) { 4323 // Set up the new opt-out. 4324 $optout->email_address = $r['email_address']; 4325 $optout->user_id = $r['user_id']; 4326 $optout->email_type = $r['email_type']; 4327 $optout->date_modified = $r['date_modified']; 4328 4329 $optout_id = $optout->save(); 4330 } 4331 4332 return $optout_id; 4333 } 4334 4335 /** 4336 * Find matching BP_Optouts. 4337 * 4338 * @since 8.0.0 4339 * 4340 * @see BP_Optout::get() for a description of parameters and return values. 4341 * 4342 * @param array $args See {@link BP_Optout::get()}. 4343 * @return array See {@link BP_Optout::get()}. 4344 */ 4345 function bp_get_optouts( $args = array() ) { 4346 $optout_class = new BP_Optout(); 4347 return $optout_class::get( $args ); 4348 } 4349 4350 /** 4351 * Delete a BP_Optout by ID. 4352 * 4353 * @since 8.0.0 4354 * 4355 * @param int $id ID of the optout to delete. 4356 * @return bool True on success, false on failure. 4357 */ 4358 function bp_delete_optout_by_id( $id = 0 ) { 4359 $optout_class = new BP_Optout(); 4360 return $optout_class::delete_by_id( $id ); 4361 }
Note: See TracChangeset
for help on using the changeset viewer.