My Pledges: Require profile to be filled out before confirming a pledge (#127)

This will disable the "join organization" button until the profile is complete, and add a second warning message to explicitly tell the user why the button is disabled.
This commit is contained in:
Kelly Dwan 2019-12-11 16:11:13 -05:00 committed by GitHub
parent bdbf6d573e
commit 636753bb00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -16,6 +16,7 @@ use WP_User, WP_Post;
*/ */
$has_contributions = $contributor_pending_posts || $contributor_publish_posts; $has_contributions = $contributor_pending_posts || $contributor_publish_posts;
$has_profile_data = $profile_data['hours_per_week'] && $profile_data['team_names'];
?> ?>
@ -30,7 +31,7 @@ $has_contributions = $contributor_pending_posts || $contributor_publish_posts;
<?php esc_html_e( 'My Pledges', 'wporg-5ftf' ); ?> <?php esc_html_e( 'My Pledges', 'wporg-5ftf' ); ?>
</h1> </h1>
<?php if ( $profile_data['hours_per_week'] && $profile_data['team_names'] ) : ?> <?php if ( $has_profile_data ) : ?>
<p class="my-pledges__dedication"> <p class="my-pledges__dedication">
<?php echo esc_html( sprintf( <?php echo esc_html( sprintf(
_n( _n(
@ -85,6 +86,17 @@ $has_contributions = $contributor_pending_posts || $contributor_publish_posts;
<div class="my-pledges__list is-pending-list"> <div class="my-pledges__list is-pending-list">
<h2><?php esc_html_e( 'Pending Pledges', 'wporg-5ftf' ); ?></h2> <h2><?php esc_html_e( 'Pending Pledges', 'wporg-5ftf' ); ?></h2>
<?php if ( ! $has_profile_data ) : ?>
<div class="notice notice-error notice-alt">
<p>
<?php echo wp_kses_data( sprintf(
__( 'You need to <a href="%s">update your profile</a> before joining an organization.', 'wporg-5ftf' ),
'https://profiles.wordpress.org/me/profile/edit/group/5/'
) ); ?>
</p>
</div>
<?php endif; ?>
<?php <?php
foreach ( $contributor_pending_posts as $contributor_post ) { foreach ( $contributor_pending_posts as $contributor_post ) {
$pledge = get_post( $contributor_post->post_parent ); $pledge = get_post( $contributor_post->post_parent );

View file

@ -4,6 +4,7 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
/** /**
* @var WP_Post $contributor_post * @var WP_Post $contributor_post
* @var bool $has_profile_data
* @var WP_Post $pledge * @var WP_Post $pledge
*/ */
@ -51,6 +52,9 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
class="button button-default" class="button button-default"
name="join_organization" name="join_organization"
value="Join Organization" value="Join Organization"
<?php if ( ! $has_profile_data ) : ?>
disabled="disabled"
<?php endif; ?>
/> />
<input <input