Manage Pledge: Enable pledge admins to edit contributors from manage form (#108)

* Add contributor management to manage form
* Check `pledge_id` to prevent returning all contributors
* Return a plain text error string – this is used in an alert box, so it can't contain HTML
* Hide confirmation when pledge is a draft
* Only enqueue script if the user is authorized
This commit is contained in:
Kelly Dwan 2019-11-26 12:57:14 -05:00
parent 286e6d55ef
commit 544fe39199
8 changed files with 110 additions and 18 deletions

View file

@ -175,8 +175,6 @@ function render_form_manage() {
return ob_get_clean();
}
$contributors = Contributor\get_pledge_contributors( $pledge_id, $status = 'all' );
if ( 'Update Pledge' === $action ) {
$results = process_form_manage( $pledge_id, $auth_token );
@ -187,7 +185,8 @@ function render_form_manage() {
}
}
$data = PledgeMeta\get_pledge_meta( $pledge_id );
$data = PledgeMeta\get_pledge_meta( $pledge_id );
$contributors = Contributor\get_pledge_contributors_data( $pledge_id );
ob_start();
$readonly = false;
@ -214,7 +213,7 @@ function process_form_manage( $pledge_id, $auth_token ) {
*/
$can_view_form = Auth\can_manage_pledge( $pledge_id, $auth_token );
if ( ! $has_valid_nonce || ! $can_view_form ) {
if ( ! $has_valid_nonce || is_wp_error( $can_view_form ) ) {
return new WP_Error(
'invalid_token',
sprintf(