Tag Archives: trigger

Submit two form by one button and redirect with jQuery Ajax

</pre>
<form id="ajaxform_member" action="" method="post">
<table class="signup-tbl">
<tr>
<td><label for="mname">Name:</label></td>
<td><input type="text" required="" id="mname" name="mname"></td>
</tr>
<tr>
<td><label for="maddress">Address:</label></td>
<td><input type="text" name="maddress" id="maddress" required></td>
</tr>
<tr>
<td><label for="mphone_num">Phone Number:</label></td>
<td><input type="text" name="mphone_num" id="mphone_num" required></td>
</tr>
<tr>
<td><label for="memail">Email:</label></td>
<td><input type="email" name="memail" id="memail" required></td>
</tr>
<tr>
<td><label for="muname">User Name:</label></td>
<td><input type="text" name="muname" id="muname" required></td>
</tr>
<tr>
<td><label for="mpass">Password:</label></td>
<td><input type="password" name="mpass" id="mpass" required></td>
</tr>
</table>
<input  class="signup-tbl-btn" id="form-ajax-submit" type="submit" value="Membership Register"  name="mregister">
<p class="status"></p>
</form>

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="raviradadiya.ommune-facilitator@gmail.com" />
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<!-- Instant Payment Notification & Return Page Details -->
<input type="hidden" name="notify_url" value="http://localhost/JobInterviewGuide/?s2member_paypal_notify=1" />
<input type="hidden" name="cancel_return" value="http://localhost/JobInterviewGuide/" />
<input type="hidden" name="return" value="http://localhost/JobInterviewGuide/?s2member_paypal_return=1" />
<input type="hidden" name="rm" value="2" />
<!-- Configures Basic Checkout Fields -->
<input type="hidden" name="lc" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="custom" value="localhost" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="page_style" value="paypal" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="item_name" value="Bronze Member / description and pricing details here." />
<input type="hidden" name="item_number" value="1" />
<!-- Configures s2Member's Unique Invoice ID/Code  -->
<input type="hidden" name="invoice" value="<?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?>" />
<!-- Identifies/Updates An Existing User/Member (when/if applicable)  -->
<input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
<input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
<!-- Identifies The Customer's IP Address For Tracking -->
<input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
<input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
<!-- Controls Modify Behavior At PayPal Checkout -->
<input type="hidden" name="modify" value="0" />
<!-- Customizes Prices, Payments & Billing Cycle -->
<!--<input type="hidden" name="amount" value="0.01" />-->
<input type="hidden" name="src" value="1" />
<input type="hidden" name="srt" value="" />
<input type="hidden" name="sra" value="1" />
<!--<input type="hidden" name="a1" value="0" />-->
<!--<input type="hidden" name="p1" value="0" />-->
<!--<input type="hidden" name="t1" value="D" />-->
<input type="hidden" name="a3" value="0.01" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="M" />
<!-- Displays The PayPal Image Button -->
<input class="paypal"  type="submit" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal" />
</form>
<pre>

ajax.signup.js

</pre>
jQuery(document).ready(function($) {
// Perform AJAX send mail and create user on form submit
$('form#ajaxform_member').on('submit', function(e){
$('form#ajaxform_member p.status').show().text(ajax_signup_object.loadingmessage);
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_signup_object.ajaxurl,
data: {
'action': 'member', //calls wp_ajax_nopriv_ajaxsignup
'mname': $('form#ajaxform_member #mname').val(),
'maddress': $('form#ajaxform_member #maddress').val(),
'mphone_num': $('form#ajaxform_member #mphone_num').val(),
'memail': $('form#ajaxform_member #memail').val(),
'muname': $('form#ajaxform_member #muname').val(),
'mpass': $('form#ajaxform_member #mpass').val(),
},
success: function (response) {
//window.location.href='http://localhost/JobInterviewGuide/paypal.php';
}
});
e.preventDefault();
});
$(".paypal").click(function(){
alert("The paragraph was clicked.");
$("#form-ajax-submit").trigger("click");
//$("paypal").trigger("click");
});
});
<pre>

Add User with Usermeta using ajax

</pre>
<form id="ajaxform_member" action="ajaxform_member" method="post">
<p class="status"></p>
<label for="mname">Name:</label>
<input type="text" name="mname" id="mname" required></br>

<label for="maddress">Address:</label>
<input type="text" name="maddress" id="maddress" required></br>

<label for="mphone_num">Phone Number:</label>
<input type="text" name="mphone_num" id="mphone_num" required></br>

<label for="memail">Email:</label>
<input type="text" name="memail" id="memail" required></br>

<label for="muname">User Name:</label>
<input type="text" name="muname" id="muname" required></br>

<label for="mpass">Password:</label>
<input type="text" name="mpass" id="mpass" required></br>

<input type="submit" value="Membership Register " name="mregister">
</form>
<pre>

functions.php

</pre>
/* Members */
function members() {
$mname = $_POST['mname'];
$maddress = $_POST['maddress'];
$mphone_num = $_POST['mphone_num'];

$memail = $_POST['memail'];
$muname = $_POST['muname'];
$mpass = $_POST['mpass'];

$userdata = array(
'user_email' => $memail,
'user_login' => $muname,
'user_pass' => $mpass,
);
$user_id = wp_insert_user($userdata);

update_user_meta($user_id, 'm_name', $mname);
update_user_meta($user_id, 'm_address', $maddress);
update_user_meta($user_id, 'm_phone_num', $mphone_num);

$blogusers = get_users( 'role=administrator' );
// Array of WP_User objects.
$user_email=array();
foreach ( $blogusers as $user ) {
$user_email[]=$user->user_email;
}
$from_email=implode(",",$user_email);

$to = array($memail,$from_email);
//$urllink = "http://steve.seomonastery.com/wp-admin"; //get_page_link(54);
$subject = 'Your Admin Password';
$body = 'Your User name is: <b>' . $muname . '</b> </br>
Your Password is: <b>' . $mpass . '</b></br>';
wp_mail($to, $subject, $body);
}
add_action( 'wp_ajax_member', 'members' );
add_action( 'wp_ajax_nopriv_member', 'members' );
<pre>

ajax-signup.php

</pre>
jQuery(document).ready(function($) {

// Perform AJAX send mail and create user on form submit
$('form#ajaxform_member').on('submit', function(e){
$('form#ajaxform_member p.status').show().text(ajax_signup_object.loadingmessage);
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_signup_object.ajaxurl,
data: {
'action': 'member', //calls wp_ajax_nopriv_ajaxsignup
'mname': $('form#ajaxform_member #mname').val(),
'maddress': $('form#ajaxform_member #maddress').val(),
'mphone_num': $('form#ajaxform_member #mphone_num').val(),
'memail': $('form#ajaxform_member #memail').val(),
'muname': $('form#ajaxform_member #muname').val(),
'mpass': $('form#ajaxform_member #mpass').val(),
},
});
e.preventDefault();
});
});
<pre>

 

%d bloggers like this: