Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UR-1057 Tweak - Improve success message after registration #618

Merged
merged 6 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions assets/js/frontend/user-registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@
// Check the position set by the admin and append message accordingly.
if ("1" === position) {
$submit_node.append(wrapper);
} else if ("2" === position) {
if (type == "message") {
$submit_node
.closest(".entry-content")
.prepend(wrapper);
$submit_node
.closest(".ur-frontend-form")
.hide();
} else {
$submit_node.append(wrapper);
}
} else {
$submit_node.prepend(wrapper);
}
Expand Down Expand Up @@ -633,7 +644,9 @@
user_registration_params.recaptcha_type
) {
captchaResponse = $this
.find('[name="cf-turnstile-response"]')
.find(
'[name="cf-turnstile-response"]'
)
.val();
} else {
captchaResponse = $this
Expand Down Expand Up @@ -933,10 +946,16 @@
window.setTimeout(
function () {
if (
typeof response.data.redirect_url !== 'undefined' &&
response.data.redirect_url
typeof response
.data
.redirect_url !==
"undefined" &&
response
.data
.redirect_url
) {
window.location = response.data.redirect_url;
window.location =
response.data.redirect_url;
} else {
location.reload();
}
Expand Down
96 changes: 42 additions & 54 deletions includes/functions-ur-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ function ur_setcookie( $name, $value, $expire = 0, $secure = false ) {
*/
function ur_enable_ur_plugin_headers( $headers ) {
if ( ! class_exists( 'UR_Plugin_Updates', false ) ) {
include_once dirname( __FILE__ ) . '/admin/updater/class-ur-plugin-updates.php';
include_once __DIR__ . '/admin/updater/class-ur-plugin-updates.php';
}

$headers['URRequires'] = UR_Plugin_Updates::VERSION_REQUIRED_HEADER;
Expand Down Expand Up @@ -1051,15 +1051,16 @@ function ur_admin_form_settings_fields( $form_id ) {
),
array(
'type' => 'select',
'label' => __( 'Success message position', 'user-registration' ),
'label' => __( 'Success message display', 'user-registration' ),
'description' => '',
'required' => false,
'id' => 'user_registration_form_setting_success_message_position',
'class' => array( 'ur-enhanced-select' ),
'input_class' => array(),
'options' => array(
'0' => __( 'Top', 'user-registration' ),
'1' => __( 'Bottom', 'user-registration' ),
'0' => esc_html__( 'Top', 'user-registration' ),
'1' => esc_html__( 'Bottom', 'user-registration' ),
'2' => esc_html__( 'Hide Form After Successful Submission', 'user-registration' ),
),
'custom_attributes' => array(),
'default' => ur_get_single_post_meta( $form_id, 'user_registration_form_setting_success_message_position', '1' ),
Expand Down Expand Up @@ -1326,15 +1327,12 @@ function ur_get_form_data_by_key( $form_data, $key = null ) {
} else {
$form_data_array[] = $field_data;
}
} else {

if ( $field_key === $key ) {
} elseif ( $field_key === $key ) {

if ( ! empty( $field_name ) ) {
$form_data_array[ $field_name ] = $field_data;
} else {
$form_data_array[] = $field_data;
}
if ( ! empty( $field_name ) ) {
$form_data_array[ $field_name ] = $field_data;
} else {
$form_data_array[] = $field_data;
}
}
}
Expand Down Expand Up @@ -1468,7 +1466,7 @@ function check_username( $username ) {
if ( isset( $matches[0][0] ) ) {
$last_char = $matches[0][0];
$strip_last_char = substr( $username, 0, -( strlen( (string) $last_char ) ) );
$last_char++;
++$last_char;
$username = $strip_last_char . $last_char;
$username = check_username( $username );

Expand Down Expand Up @@ -1565,7 +1563,7 @@ function ur_get_recaptcha_node( $context, $recaptcha_enabled = false ) {
} else {
wp_localize_script( $enqueue_script, 'ur_recaptcha_code', $ur_google_recaptcha_code );
}
$rc_counter++;
++$rc_counter;
}

if ( 'v3' === $recaptcha_type ) {
Expand Down Expand Up @@ -1602,29 +1600,25 @@ function ur_get_recaptcha_node( $context, $recaptcha_enabled = false ) {
} else {
$recaptcha_node = '';
}
} else {
if ( 'v2' === $recaptcha_type && $invisible_recaptcha ) {
if ( 'login' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_login" class="g-recaptcha" data-size="invisible"></div>';
} elseif ( 'register' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_register" class="g-recaptcha" data-size="invisible"></div>';
} elseif ( 'lost_password' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_lost_password" class="g-recaptcha" data-size="invisible"></div>';
} else {
$recaptcha_node = '';
}
} elseif ( 'v2' === $recaptcha_type && $invisible_recaptcha ) {
if ( 'login' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_login" class="g-recaptcha" data-size="invisible"></div>';
} elseif ( 'register' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_register" class="g-recaptcha" data-size="invisible"></div>';
} elseif ( 'lost_password' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_lost_password" class="g-recaptcha" data-size="invisible"></div>';
} else {
if ( 'login' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_login" class="g-recaptcha"></div>';

} elseif ( 'register' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_register" class="g-recaptcha"></div>';
} elseif ( 'lost_password' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_lost_password" class="g-recaptcha"></div>';
} else {
$recaptcha_node = '';
}
$recaptcha_node = '';
}
} elseif ( 'login' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_login" class="g-recaptcha"></div>';

} elseif ( 'register' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_register" class="g-recaptcha"></div>';
} elseif ( 'lost_password' === $context ) {
$recaptcha_node = '<div id="node_recaptcha_lost_password" class="g-recaptcha"></div>';
} else {
$recaptcha_node = '';
}
} else {
$recaptcha_node = '';
Expand Down Expand Up @@ -1702,12 +1696,10 @@ function ur_get_user_status( $user_status, $user_email_status ) {
array_push( $status, 'Pending' );
} elseif ( '-1' === $user_status || '-1' === $user_email_status ) {
array_push( $status, 'Denied' );
} else {
if ( $user_email_status ) {
} elseif ( $user_email_status ) {
array_push( $status, 'Verified' );
} else {
array_push( $status, 'Approved' );
}
} else {
array_push( $status, 'Approved' );
}
return $status;
}
Expand Down Expand Up @@ -2119,11 +2111,9 @@ function ur_get_valid_form_data_format( $new_string, $post_key, $profile, $value
}
}
$value = ! empty( $attachment_ids ) ? $attachment_ids : $value;
} else {
} elseif ( wp_http_validate_url( $value ) ) {

if ( wp_http_validate_url( $value ) ) {
$value = attachment_url_to_postid( $value );
}
}
break;
}
Expand Down Expand Up @@ -3105,7 +3095,7 @@ function ur_get_user_roles( $user_id ) {
*/
function ur_upload_profile_pic( $valid_form_data, $user_id ) {
$attachment_id = array();
$upload_path = apply_filters( 'user_registration_profile_pic_upload_url', UR_UPLOAD_PATH . 'profile-pictures' ); /*Get path of upload dir of WordPress*/
$upload_path = apply_filters( 'user_registration_profile_pic_upload_url', UR_UPLOAD_PATH . 'profile-pictures' ); /*Get path of upload dir of WordPress*/

// Checks if the upload directory exists and create one if not.
if ( ! file_exists( $upload_path ) ) {
Expand Down Expand Up @@ -3573,14 +3563,12 @@ function ur_process_login( $nonce_value ) {
} else {
if ( in_array( 'administrator', $user->roles, true ) && ur_option_checked( 'user_registration_login_options_prevent_core_login', true ) ) {
$redirect = admin_url();
} else {
if ( ! empty( $post['redirect'] ) ) {
} elseif ( ! empty( $post['redirect'] ) ) {
$redirect = esc_url_raw( wp_unslash( $post['redirect'] ) );
} elseif ( wp_get_raw_referer() ) {
$redirect = wp_get_raw_referer();
} else {
$redirect = get_home_url();
}
} elseif ( wp_get_raw_referer() ) {
$redirect = wp_get_raw_referer();
} else {
$redirect = get_home_url();
}

$redirect = apply_filters( 'user_registration_login_redirect', $redirect, $user );
Expand Down Expand Up @@ -3999,9 +3987,9 @@ function ur_add_links_to_top_nav( $wp_admin_bar ) {
$form_id,
admin_url( 'admin.php?page=add-new-registration' )
),
'meta' => array(
'target' => "_blank"
)
'meta' => array(
'target' => '_blank',
),
)
);
}
Expand Down
Loading