Skip to content

Commit

Permalink
Membership Requests: Change labels on register page.
Browse files Browse the repository at this point in the history
We are using the standard "register" form to collect
membership requests, so we need to change the labels
in many cases to avoid confusion. Also ensure that users
can access the registration page when membership
requests are enabled.

See #8582.

git-svn-id: https://buddypress.svn.wordpress.org/trunk@13170 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
  • Loading branch information
dcavins committed Dec 10, 2021
1 parent 0817c97 commit dd528d1
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 24 deletions.
6 changes: 5 additions & 1 deletion src/bp-core/bp-core-template.php
Expand Up @@ -3192,7 +3192,11 @@ function bp_get_title_parts( $seplocation = 'right' ) {

// Sign up page.
} elseif ( bp_is_register_page() ) {
$bp_title_parts = array( __( 'Create an Account', 'buddypress' ) );
if ( bp_get_membership_requests_required() ) {
$bp_title_parts = array( __( 'Request Membership', 'buddypress' ) );
} else {
$bp_title_parts = array( __( 'Create an Account', 'buddypress' ) );
}

// Activation page.
} elseif ( bp_is_activation_page() ) {
Expand Down
52 changes: 37 additions & 15 deletions src/bp-members/bp-members-functions.php
Expand Up @@ -2444,25 +2444,47 @@ function bp_core_signup_disable_inactive( $user = null, $username = '', $passwor
}

// Unactivated user account found!
// Set up the feedback message.
$signup_id = $signup['signups'][0]->signup_id;

$resend_url_params = array(
'action' => 'bp-resend-activation',
'id' => $signup_id,
);
/*
* Don't allow users to resend their own activation email
* when membership requests are enabled.
*/
if ( bp_get_membership_requests_required() ) {
$error_message = sprintf(
'<strong>%1$s</strong> %2$s',
esc_html_x( 'Error:', 'Warning displayed on the WP Login screen', 'buddypress' ),
esc_html_x( 'Your membership request has not yet been approved.', 'Error message displayed on the WP Login screen', 'buddypress' )
);
} else {
// Set up the feedback message.
$signup_id = $signup['signups'][0]->signup_id;

$resend_url = wp_nonce_url(
add_query_arg( $resend_url_params, wp_login_url() ),
'bp-resend-activation'
);
$resend_url_params = array(
'action' => 'bp-resend-activation',
'id' => $signup_id,
);

$resend_string = '<br /><br />';
$resend_url = wp_nonce_url(
add_query_arg( $resend_url_params, wp_login_url() ),
'bp-resend-activation'
);

/* translators: %s: the activation url */
$resend_string .= sprintf( __( 'If you have not received an email yet, <a href="%s">click here to resend it</a>.', 'buddypress' ), esc_url( $resend_url ) );
$error_message = sprintf(
'<strong>%1$s</strong> %2$s<br /><br />%3$s',
esc_html_x( 'Error:', 'Warning displayed on the WP Login screen', 'buddypress' ),
esc_html_x( 'Your account has not been activated. Check your email for the activation link.', 'Error message displayed on the WP Login screen', 'buddypress' ),
sprintf(
/* translators: %s: the link to resend the activation email. */
esc_html_x( 'If you have not received an email yet, %s.', 'WP Login screen message', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( $resend_url ),
esc_html_x( 'click here to resend it', 'Text of the link to resend the activation email', 'buddypress' )
)
)
);
}

return new WP_Error( 'bp_account_not_activated', __( '<strong>Error</strong>: Your account has not been activated. Check your email for the activation link.', 'buddypress' ) . $resend_string );
return new WP_Error( 'bp_account_not_activated', $error_message );
}
add_filter( 'authenticate', 'bp_core_signup_disable_inactive', 30, 3 );

Expand Down
15 changes: 15 additions & 0 deletions src/bp-members/bp-members-membership-requests.php
Expand Up @@ -258,6 +258,21 @@ function bp_members_membership_requests_delete_notifications_on_change( $signup_
add_action( 'bp_core_signup_after_activate', 'bp_members_membership_requests_delete_notifications_on_change' );
add_action( 'bp_core_signup_after_delete', 'bp_members_membership_requests_delete_notifications_on_change' );

/**
* In the Nouveau template pack, when membership requests are required,
* change registration form submit button label to "Submit Request".
*
* @since 10.0.0
*
* @return string $retval the HTML for the request membership link.
*/
function bp_members_membership_requests_filter_complete_signup_button( $buttons ) {

$buttons['register']['attributes']['value'] = __( 'Submit Request', 'buddypress' );
return $buttons;
}
add_filter( 'bp_nouveau_get_submit_button', 'bp_members_membership_requests_filter_complete_signup_button' );

/**
* Administration: Change certain behavior and labels
* on the WP Admin > Users > Manage Signups screen.
Expand Down
12 changes: 10 additions & 2 deletions src/bp-members/classes/class-bp-registration-theme-compat.php
Expand Up @@ -97,10 +97,18 @@ public function template_hierarchy( $templates ) {
public function dummy_post() {
// Registration page.
if ( bp_is_register_page() ) {
$title = __( 'Create an Account', 'buddypress' );
if ( bp_get_membership_requests_required() ) {
$title = __( 'Request Membership', 'buddypress' );
} else {
$title = __( 'Create an Account', 'buddypress' );
}

if ( 'completed-confirmation' == bp_get_current_signup_step() ) {
$title = __( 'Check Your Email To Activate Your Account!', 'buddypress' );
if ( bp_get_membership_requests_required() ) {
$title = __( 'Your Membership Request has been submitted.', 'buddypress' );
} else {
$title = __( 'Check Your Email To Activate Your Account!', 'buddypress' );
}
}

// Activation page.
Expand Down
6 changes: 4 additions & 2 deletions src/bp-members/screens/register.php
Expand Up @@ -61,7 +61,9 @@ function bp_core_screen_signup() {
}
}

if ( ! bp_get_signup_allowed() && ! $active_invite ) {
$requests_enabled = bp_get_membership_requests_required();

if ( ! bp_get_signup_allowed() && ! $active_invite && ! $requests_enabled ) {
$bp->signup->step = 'registration-disabled';
// If the signup page is submitted, validate and save.
} elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) {
Expand Down Expand Up @@ -197,7 +199,7 @@ function bp_core_screen_signup() {
// No errors! Let's register those deets.
$active_signup = bp_core_get_root_option( 'registration' );

if ( 'none' != $active_signup ) {
if ( 'none' != $active_signup || $requests_enabled ) {

// Make sure the extended profiles module is enabled.
if ( bp_is_active( 'xprofile' ) ) {
Expand Down
15 changes: 12 additions & 3 deletions src/bp-templates/bp-legacy/buddypress/members/register.php
Expand Up @@ -351,10 +351,17 @@
*
* @since 1.1.0
*/
do_action( 'bp_before_registration_submit_buttons' ); ?>
do_action( 'bp_before_registration_submit_buttons' );

if ( bp_get_membership_requests_required() ) {
$button_text = __( 'Submit Request', 'buddypress' );
} else {
$button_text = __( 'Complete Sign Up', 'buddypress' );
}
?>

<div class="submit">
<input type="submit" name="signup_submit" id="signup_submit" value="<?php esc_attr_e( 'Complete Sign Up', 'buddypress' ); ?>" />
<input type="submit" name="signup_submit" id="signup_submit" value="<?php echo esc_attr( $button_text ); ?>" />
</div>

<?php
Expand Down Expand Up @@ -390,7 +397,9 @@
do_action( 'bp_before_registration_confirmed' ); ?>

<div id="template-notices" role="alert" aria-atomic="true">
<?php if ( bp_registration_needs_activation() ) : ?>
<?php if ( bp_get_membership_requests_required() ) : ?>
<p><?php _e( 'You have successfully submitted your membership request! Our site moderators will review your submission and send you an activation email if your request is approved.', 'buddypress' ); ?></p>
<?php elseif ( bp_registration_needs_activation() ) : ?>
<p><?php _e( 'You have successfully created your account! To begin using this site you will need to activate your account via the email we have just sent to your address.', 'buddypress' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have successfully created your account! Please log in using the username and password you have just created.', 'buddypress' ); ?></p>
Expand Down
4 changes: 3 additions & 1 deletion src/bp-templates/bp-nouveau/includes/functions.php
Expand Up @@ -1122,7 +1122,9 @@ function bp_nouveau_get_user_feedback( $feedback_id = '' ) {
/*
* Adjust some messages to the context.
*/
if ( 'completed-confirmation' === $feedback_id && bp_registration_needs_activation() ) {
if ( 'completed-confirmation' === $feedback_id && bp_get_membership_requests_required() ) {
$feedback_messages['completed-confirmation']['message'] = __( 'You have successfully submitted your membership request! Our site moderators will review your submission and send you an activation email if your request is approved.', 'buddypress' );
} elseif ( 'completed-confirmation' === $feedback_id && bp_registration_needs_activation() ) {
$feedback_messages['completed-confirmation']['message'] = __( 'You have successfully created your account! To begin using this site you will need to activate your account via the email we have just sent to your address.', 'buddypress' );
} elseif ( 'member-notifications-none' === $feedback_id ) {
$is_myprofile = bp_is_my_profile();
Expand Down

0 comments on commit dd528d1

Please sign in to comment.