Last active
September 30, 2019 08:47
-
-
Save antcms/5ee9f6e77a5decd8f228818f0b546afc to your computer and use it in GitHub Desktop.
Dynamic Registration form for WordPress Simple Membership Plugin (with Form Builder Addon). Choose Membership level from a Select Menu and div below dynamically populates with the correct form for that level. Requires jQuery. https://simple-membership-plugin.com / https://simple-membership-plugin.com/simple-membership-form-builder-addon/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="registration"> | |
<h2 class="title">Register Here:</h2> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var hideAll = function() { | |
$('div[class^=option]').hide(); | |
} | |
$('#select').on('change', function() { | |
hideAll(); | |
var category = $(this).val(); | |
$('.' + category).show(); | |
}); | |
}); | |
</script> | |
<form method="post"> | |
<label for="option">To register start here: </label> | |
<select name="select" id="select"> | |
<option value="option1">Choose your membership level…</option> | |
<?php | |
$squery = "SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id !=1 "; | |
$levels = $wpdb->get_results($squery, ARRAY_A); | |
foreach ($levels as $level) { | |
$mlvalue = $level['id']; | |
$mlname = $level['alias']; | |
echo '<option value="option' . $mlvalue . '">' . $mlname . '</option>'; | |
} | |
?> | |
</select> | |
</form> | |
<div class="option1" style="display:block;"> | |
<p>To begin please select the membership level you wish to sign up for from the list above.</p> | |
</div> | |
<?php | |
$dquery = "SELECT * FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id !=1 "; | |
$levels = $wpdb->get_results($dquery, ARRAY_A); | |
foreach ($levels as $level) { | |
$mlvalue = $level['id']; | |
$mlname = $level['alias']; | |
echo '<div class="option' . $mlvalue . '" style="display:none;"><h4>' . $mlname . ' Registration</h4>' . do_shortcode('[swpm_registration_form level=' . $mlvalue . ']') . '</div>'; | |
} | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Its not working. Can you check?