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

WIP: Issues 1384 #1836

Merged
merged 4 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 10 additions & 5 deletions assets/js/frontend/give-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,25 @@ jQuery(document).ready(function ($) {
give_user_pass: this_form.find('[name=give_user_pass]').val()
};

$.post(give_global_vars.ajaxurl, data, function (data) {

$.post(give_global_vars.ajaxurl, data, function (response) {
//user is logged in
if ($.trim(data) == 'success') {
if ( $.trim( typeof ( response.success ) ) != undefined && response.success == true && typeof ( response.data ) != undefined ) {

//remove errors
this_form.find('.give_errors').remove();
//reload the selected gateway so it contains their logged in information

// Login successfully message.
this_form.find( '#give-payment-mode-select' ).after( response.data );
this_form.find( '.give_notices.give_errors' ).delay(5000).slideUp();

//reload the selected gateway so it contains their logged in information
give_load_gateway(this_form, this_form.find('.give-gateway-option-selected input').val());
} else {
//Login failed, show errors
this_form.find('[id^=give-login-fields] input[type=submit]').val(complete_purchase_val);
this_form.find('.give-loading-animation').fadeOut();
this_form.find('.give_errors').remove();
this_form.find('[id^=give-user-login-submit]').before(data);
this_form.find('[id^=give-user-login-submit]').before( response.data );
}
});

Expand Down
2 changes: 1 addition & 1 deletion assets/js/frontend/give-ajax.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/frontend/give.all.min.js

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions includes/process-donation.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
* @return void
*/
function give_process_form_login() {

$is_ajax = isset( $_POST['give_ajax'] );

$user_data = give_donation_form_validate_user_login();
Expand All @@ -219,8 +218,11 @@ function give_process_form_login() {
*
* @since 1.0
*/
do_action( 'give_ajax_donation_errors' );
give_die();
ob_start();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Commit id: raftaar1191@41bf6bf

do_action( 'give_ajax_donation_errors' );
$message = ob_get_contents();
ob_end_clean();
wp_send_json_error( $message );
} else {
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit;
Expand All @@ -230,8 +232,17 @@ function give_process_form_login() {
give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );

if ( $is_ajax ) {
echo 'success';
give_die();
$message = Give()->notices->print_frontend_notice(
sprintf(
/* translators: %s: user first name */
esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
( isset( $user_data['user_first'] ) && ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raftaar1191 Do not use isset, empty will check for both

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

),
false,
'success'
);

wp_send_json_success( $message );
} else {
wp_redirect( $_SERVER['HTTP_REFERER'] );
}
Expand Down