mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-02 01:01:18 +03:00
Manage Pledge: Notify removed contributors
This commit is contained in:
parent
b1cbcdb01b
commit
7260c9b766
|
@ -2,7 +2,7 @@
|
||||||
namespace WordPressDotOrg\FiveForTheFuture\Contributor;
|
namespace WordPressDotOrg\FiveForTheFuture\Contributor;
|
||||||
|
|
||||||
use WordPressDotOrg\FiveForTheFuture;
|
use WordPressDotOrg\FiveForTheFuture;
|
||||||
use WordPressDotOrg\FiveForTheFuture\{ Pledge, XProfile };
|
use WordPressDotOrg\FiveForTheFuture\{ Email, Pledge, XProfile };
|
||||||
use WP_Error, WP_Post, WP_User;
|
use WP_Error, WP_Post, WP_User;
|
||||||
|
|
||||||
defined( 'WPINC' ) || die();
|
defined( 'WPINC' ) || die();
|
||||||
|
@ -177,8 +177,13 @@ function add_pledge_contributors( $pledge_id, $contributors ) {
|
||||||
* @return false|WP_Post|null
|
* @return false|WP_Post|null
|
||||||
*/
|
*/
|
||||||
function remove_contributor( $contributor_post_id ) {
|
function remove_contributor( $contributor_post_id ) {
|
||||||
$pledge_id = get_post( $contributor_post_id )->post_parent;
|
$contributor = get_post( $contributor_post_id );
|
||||||
$result = wp_trash_post( $contributor_post_id );
|
$pledge_id = $contributor->post_parent;
|
||||||
|
$result = wp_trash_post( $contributor_post_id );
|
||||||
|
|
||||||
|
if ( $result && 'publish' === $contributor->post_status ) {
|
||||||
|
Email\send_contributor_removed_email( $pledge_id, $contributor );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: Fires when a contributor is removed from a pledge.
|
* Action: Fires when a contributor is removed from a pledge.
|
||||||
|
|
|
@ -115,11 +115,25 @@ function send_contributor_confirmation_emails( $pledge_id, $contributor_id = nul
|
||||||
|
|
||||||
"If {$pledge->post_title} isn't sponsoring your contributions, then you can ignore this email, and you won't be listed on their pledge.";
|
"If {$pledge->post_title} isn't sponsoring your contributions, then you can ignore this email, and you won't be listed on their pledge.";
|
||||||
|
|
||||||
$user = get_user_by( 'login', $contributor->post_title );
|
|
||||||
send_email( $user->user_email, $subject, $message, $pledge_id );
|
send_email( $user->user_email, $subject, $message, $pledge_id );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the removed contributor an email to notify them after removal.
|
||||||
|
*
|
||||||
|
* @param int $pledge_id
|
||||||
|
* @param WP_Post $contributor
|
||||||
|
*/
|
||||||
|
function send_contributor_removed_email( $pledge_id, $contributor ) {
|
||||||
|
$pledge = get_post( $pledge_id );
|
||||||
|
$subject = "Removed from {$pledge->post_title} sponsorship";
|
||||||
|
$message = "Howdy\n\n{$pledge->post_title} has removed you from their pledge.";
|
||||||
|
|
||||||
|
$user = get_user_by( 'login', $contributor->post_title );
|
||||||
|
send_email( $user->user_email, $subject, $message, $pledge_id );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email the pledge admin a temporary link they can use to manage their pledge.
|
* Email the pledge admin a temporary link they can use to manage their pledge.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue