Reputation: 209
I'm using a template for Wordpress that has membership functions built-in, including membership plans.
What I'm trying to do is duplicate the Registration page and have everyone who create an account using the signup form on this page get automatically subscribed to a paid membership plan for free.
So I created a new signup page by duplicating the original one. I asked the developer of the template and he said I need to use this function somewhere on the page to subscribe the users to the paid plan. Here's the function:
ThemexCourse::subscribeUser(5244, $user, true);
5244 is the ID of the paid plan on the site.
Any idea how to configure the signup form using this function so that everyone who signs up gets subscribed to the paid plan?
Here's the sign up form code:
<?php
/*
Template Name: Custom Registration
*/
?>
<?php get_header(); ?>
<?php if(get_option('users_can_register')) { ?>
<h1><?php _e('Register Your Account','academy'); ?></h1>
<form class="ajax-form formatted-form" action="<?php echo AJAX_URL; ?>" method="POST">
<div class="message"></div>
<div class="sixcol column">
<div class="field-wrapper">
<input type="text" name="user_login" placeholder="<?php _e('Username','academy'); ?>" />
</div>
</div>
<div class="sixcol column last">
<div class="field-wrapper">
<input type="text" name="user_email" placeholder="<?php _e('Email','academy'); ?>" />
</div>
</div>
<div class="clear"></div>
<div class="sixcol column">
<div class="field-wrapper">
<input type="password" name="user_password" placeholder="<?php _e('Password','academy'); ?>" />
</div>
</div>
<div class="sixcol column last">
<div class="field-wrapper">
<input type="password" name="user_password_repeat" placeholder="<?php _e('Repeat Password','academy'); ?>" />
</div>
</div>
<div class="clear"></div>
<?php if(ThemexCore::checkOption('user_captcha')) { ?>
<div class="form-captcha">
<img src="<?php echo THEMEX_URI; ?>assets/images/captcha/captcha.php" alt="" />
<input type="text" name="captcha" id="captcha" size="6" value="" />
</div>
<div class="clear"></div>
<?php } ?>
<a href="#" class="button submit-button left"><span class="button-icon register"></span><?php _e('Register','academy'); ?></a>
<div class="form-loader"></div>
<input type="hidden" name="user_action" value="register_user" />
<input type="hidden" name="user_redirect" value="<?php echo themex_value($_POST, 'user_redirect'); ?>" />
<input type="hidden" name="nonce" class="nonce" value="<?php echo wp_create_nonce(THEMEX_PREFIX.'nonce'); ?>" />
<input type="hidden" name="action" class="action" value="<?php echo THEMEX_PREFIX; ?>update_user" />
</form>
<?php } ?>
<div class="clear"></div>
<?php
$query=new WP_Query(array(
'post_type' => 'page',
'meta_key' => '_wp_page_template',
'meta_value' => 'template-register.php'
));
if($query->have_posts()) {
$query->the_post();
echo '<br />';
the_content();
}
?>
<?php get_footer(); ?>
Upvotes: 0
Views: 250
Reputation: 91
Such customization belong to the Plugins, not themes indeed. As mention in Customizing registration form codex page you may hook to one of the action hooks, to both customize the registration form and do some action after the form posts. The 3 action hooks are register_form, register_post, user_register.
For your particular question the action hook user_register must be hooked with your function preferably in a plugin.
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
....
ThemexCourse::subscribeUser(5244, $user, true);
....
}
Upvotes: 0