Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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/
<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&hellip;</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>
@salmancth

This comment has been minimized.

Copy link

salmancth commented Sep 30, 2019

Its not working. Can you check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.