latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

s2Member shortcode over ajax.

Home Forums Community Forum s2Member shortcode over ajax.

This topic contains 2 replies, has 2 voices. Last updated by  Bruce 3 years, 8 months ago.

Topic Author Topic
Posted: Monday Apr 15th, 2013 at 9:27 am #47493

I have coupon codes that allow for 100% discount on membership. As s2Member doesn’t currently support this, I’ve elected to load the s2 shortcode in via ajax after validation. Something like this:

When a visitor types in a coupon into the input and clicks Validate, an ajax call is made, which validates/rejects their coupon. If the coupon is valid, the php does something like this:

$html = do_shortcode('[s2Member etc etc]');
echo json_encode($html);
die();

The javascript then appends the html result onto the same page, allowing the visitor to continue with registration.
Like so:

success: function(value) {
if(value["type"]=="error"){
    $(".error").empty().append(value["html"]);
}
else{
    $(".error").empty().append("Success! Your Member ID is valid.");
    $("#validate-results-html").empty().append(value["html"]);
}

This is all workng fine until it gets to the reCaptcha – the recaptcha form will not show up! The form says “Security Code” with a horizontal rule below it, but the reCaptcha input never appears.

Another weird thing is that after the form is appended to the document, I can see a get request made to https://www.google.com/recaptcha/api/challenge?k=xxx&_=xxx (where xxx’s are replaced by long sequences of digits) with a correct looking response (a RecaptchaState object with correct looking properties).

I don’t see a single error at any point in Chrome’s console.

Attempting to submit the form as-is results in a post to /wp-admin/admin-ajax.php, with the screen showing a white screen with a ‘0’ (rejected/bad ajax call?).

Any help?

Updated to include comment of mine below (can’t seem to delete it).
I removed the captcha=”clean” attribute from my shortcode; the Security code section is gone, but the form still submits and returns a white page with the 0.

The form submits to /wp-admin/admin-ajax.php, but I cannot figure out what action/function it uses to process the submitted data. Perhaps the problem is that the ajax function has not been registered with WordPress when I am dynamically inserting the shortcode?

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Monday Apr 15th, 2013 at 10:05 am #47496

Comment added to original question. Please delete this comment.

Posted: Monday Apr 15th, 2013 at 8:54 pm #47558
Bruce
Username: Bruce
Staff Member

Thank you for reporting this important issue.

s2Member does some fancy JavaScript / AJAX calls here, and you’ll need to create your shortcodes through PHP. Sorry for the inconvenience.

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.