'0',
'code' => '0',
'codepass' => array('0'),
'captcha' => '0',
'disclaimer' => '0',
'disclaimer_content' => '',
'email_exists' => '0',
'firstname' => '0',
'lastname' => '0',
'website' => '0',
'aim' => '0',
'yahoo' => '0',
'jabber' => '0',
'about' => '0',
'profile_req' => array('0')
);
# Get Previously Saved Items and put into new Settings
if( get_option("regplus_password") )
$default['password'] = get_option("regplus_password");
if( get_option("regplus_code") )
$default['code'] = get_option("regplus_code");
if( get_option("regplus_codepass") )
$default['codepass'] = get_option("regplus_codepass");
if( get_option("regplus_captcha") )
$default['captcha'] = get_option("regplus_captcha");
#Delete Previous Saved Items
delete_option('regplus_password');
delete_option('regplus_code');
delete_option('regplus_codepass');
delete_option('regplus_captcha');
#Set Default Settings
if( !get_option('register_plus') )
add_option( 'register_plus', $default );
}
function SaveSettings(){
check_admin_referer('regplus-update-options');
$update = get_option( 'register_plus' );
$update["password"] = $_POST['regplus_password'];
$update["code"] = $_POST['regplus_code'];
if( $_POST['regplus_code'] )
$update["codepass"] = $_POST['regplus_codepass'];
$update["captcha"] = $_POST['regplus_captcha'];
$update["disclaimer"] = $_POST['regplus_disclaimer'];
$update["disclaimer_content"] = $_POST['regplus_disclaimer_content'];
$update["email_exists"] = $_POST['regplus_email_exists'];
$update["firstname"] = $_POST['regplus_firstname'];
$update["lastname"] = $_POST['regplus_lastname'];
$update["website"] = $_POST['regplus_website'];
$update["aim"] = $_POST['regplus_aim'];
$update["yahoo"] = $_POST['regplus_yahoo'];
$update["jabber"] = $_POST['regplus_jabber'];
$update["about"] = $_POST['regplus_about'];
$update["profile_req"] = $_POST['regplus_profile_req'];
if( $_POST['label'] ){
foreach( $_POST['label'] as $k => $field ){
if( $field )
$custom[$k] = array( 'label' => $field, 'profile' => $_POST['profile'][$k], 'reg' => $_POST['reg'][$k], 'required' => $_POST['required'][$k] );
}
}
update_option( 'register_plus_custom', $custom );
update_option( 'register_plus', $update );
$_POST['notice'] = __('Settings Saved', 'regplus');
}
function SettingsHead(){
$regplus = get_option( 'register_plus' );
?>
' . $_POST['notice'] . '.
';
if( !is_array($regplus['profile_req']) )
$regplus['profile_req'] = array();
if( is_array($regplus['codepass']) ){
foreach( $regplus['codepass'] as $code ){
$codes .= '';
}
}
if( is_array($regplus_custom) ){
foreach( $regplus_custom as $k => $v ) {
$rows .= '
|
|
';
}
}
?>
errors['email_exists'] ){
unset($errors->errors['email_exists']);
}
}
if( $regplus['firstname'] && in_array('firstname', $regplus['profile_req']) ){
if(empty($_POST['firstname']) || $_POST['firstname'] == ''){
$errors->add('empty_firstname', __('ERROR: Please enter your First Name.', 'regplus'));
}
}
if( $regplus['lastname'] && in_array('lastname', $regplus['profile_req']) ){
if(empty($_POST['lastname']) || $_POST['lastname'] == ''){
$errors->add('empty_lastname', __('ERROR: Please enter your Last Name.', 'regplus'));
}
}
if( $regplus['website'] && in_array('website', $regplus['profile_req']) ){
if(empty($_POST['website']) || $_POST['website'] == ''){
$errors->add('empty_website', __('ERROR: Please enter your Website URL.', 'regplus'));
}
}
if( $regplus['aim'] && in_array('aim', $regplus['profile_req']) ){
if(empty($_POST['aim']) || $_POST['aim'] == ''){
$errors->add('empty_aim', __('ERROR: Please enter your AIM username.', 'regplus'));
}
}
if( $regplus['yahoo'] && in_array('yahoo', $regplus['profile_req']) ){
if(empty($_POST['yahoo']) || $_POST['yahoo'] == ''){
$errors->add('empty_yahoo', __('ERROR: Please enter your Yahoo IM username.', 'regplus'));
}
}
if( $regplus['jabber'] && in_array('jabber', $regplus['profile_req']) ){
if(empty($_POST['jabber']) || $_POST['jabber'] == ''){
$errors->add('empty_jabber', __('ERROR: Please enter your Jabber / Google Talk username.', 'regplus'));
}
}
if( $regplus['about'] && in_array('about', $regplus['profile_req']) ){
if(empty($_POST['about']) || $_POST['about'] == ''){
$errors->add('empty_about', __('ERROR: Please enter some information About Yourself.', 'regplus'));
}
}
foreach( $regplus_custom as $k=>$v ){
if( $v['required'] && $v['reg'] ){
$id = $this->Label_ID($v['label']);
if(empty($_POST[$id]) || $_POST[$id] == ''){
$errors->add('empty_' . $id, __('ERROR: Please enter your ' . $v['label'] . '.', 'regplus'));
}
}
}
if ( $regplus['password'] ){
if(empty($_POST['pass1']) || $_POST['pass1'] == '' || empty($_POST['pass2']) || $_POST['pass2'] == ''){
$errors->add('empty_password', __('ERROR: Please enter a Password.', 'regplus'));
}elseif($_POST['pass1'] !== $_POST['pass2']){
$errors->add('password_mismatch', __('ERROR: Your Password does not match.', 'regplus'));
}elseif(strlen($_POST['pass1'])<6){
$errors->add('password_length', __('ERROR: Your Password must be at least 6 characters in length.', 'regplus'));
}else{
$_POST['user_pw'] = $_POST['pass1'];
}
}
if ( $regplus['code'] ){
if(empty($_POST['regcode']) || $_POST['regcode'] == ''){
$errors->add('empty_regcode', __('ERROR: Please enter the Invitation Code.', 'regplus'));
}elseif( !in_array($_POST['regcode'], $regplus['codepass']) ){
$errors->add('regcode_mismatch', __('ERROR: Your Invitation Code is incorrect.', 'regplus'));
}
}
if ( $regplus['captcha'] ){
$key=substr($_SESSION['key'],0,5);
$number = $_POST['captcha'];
if($number!=$key){
$errors->add('captcha_mismatch', __('ERROR: Image Validation does not match.', 'regplus'));
}
}
if ( $regplus['disclaimer'] ){
if(!$_POST['disclaimer']){
$errors->add('disclaimer', __('ERROR: Please accept the Disclaimer.', 'regplus'));
}
}
return $errors;
}
# Add Fields to Register Form
function RegForm(){
$regplus = get_option( 'register_plus' );
$regplus_custom = get_option( 'register_plus_custom' );
if( !is_array( $regplus_custom ) ) $regplus_custom = array();
if ( $regplus['firstname'] ){
?>
$v){
if( $v['reg'] ){
$id = $this->Label_ID($v['label']);
?>
/>
0){
$top = '' . __('Additional Information', 'regplus') . '
';
}
echo $top;
foreach( $regplus_custom as $k=>$v ){
if( $v['profile'] ){
$id = $this->Label_ID($v['label']);
$value = get_usermeta( $user_ID, $id );
?>
| : |
|
}
}
echo $bottom;
}
function SaveProfile(){
global $wpdb, $user_ID;
get_currentuserinfo();
if( $_GET['user_id'] ) $user_ID = $_GET['user_id'];
$regplus_custom = get_option( 'register_plus_custom' );
if( !is_array( $regplus_custom ) ) $regplus_custom = array();
foreach( $regplus_custom as $k=>$v ){
if( $v['profile'] ){
$key = $this->Label_ID($v['label']);
$value = $wpdb->prepare($_POST[$key]);
update_usermeta($user_ID ,$key ,$value);
}
}
}
}
}# END Class RegisterPlugPlugin
# Run The Plugin!
if( class_exists('RegisterPlugPlugin') ){
$register_plus = new RegisterPlugPlugin();
}
# Override set user password and send email to User #
if ( !function_exists('wp_new_user_notification') ) :
function wp_new_user_notification($user_id, $plaintext_pass = '') {
$user = new WP_User($user_id);
#-- REGISTER --#
global $wpdb, $register_plus;
$regplus = get_option( 'register_plus' );
$regplus_custom = get_option( 'register_plus_custom' );
if( !is_array( $regplus_custom ) ) $regplus_custom = array();
if( $regplus['password'] && $_POST['user_pw'] )
$plaintext_pass = $wpdb->prepare($_POST['user_pw']);
if( $regplus['firstname'] && $_POST['firstname'] )
update_usermeta( $user_id, 'first_name', $wpdb->prepare($_POST['firstname']));
if( $regplus['lastname'] && $_POST['lastname'] )
update_usermeta( $user_id, 'last_name', $wpdb->prepare($_POST['lastname']));
if( $regplus['website'] && $_POST['website'] )
update_usermeta( $user_id, 'user_url', $wpdb->prepare($_POST['website']));
if( $regplus['aim'] && $_POST['aim'] )
update_usermeta( $user_id, 'aim', $wpdb->prepare($_POST['aim']));
if( $regplus['yahoo'] && $_POST['yahoo'] )
update_usermeta( $user_id, 'yim', $wpdb->prepare($_POST['yahoo']));
if( $regplus['jabber'] && $_POST['jabber'] )
update_usermeta( $user_id, 'jabber', $wpdb->prepare($_POST['jabber']));
if( $regplus['about'] && $_POST['about'] )
update_usermeta( $user_id, 'description', $wpdb->prepare($_POST['about']));
if( $regplus['code'] && $_POST['regcode'] )
update_usermeta( $user_id, 'invite_code', $wpdb->prepare($_POST['regcode']));
foreach( $regplus_custom as $k=>$v ){
$id = $register_plus->Label_ID($v['label']);
if( $v['reg'] && $_POST[$id] ){
update_usermeta( $user_id, $id, $wpdb->prepare($_POST[$id]));
}
}
#-- END REGISTER --#
wp_set_password($plaintext_pass, $user_id);
$user_login = stripslashes($user->user_login);
$user_email = stripslashes($user->user_email);
$message = sprintf(__('New user Register on your blog %s:'), get_option('blogname')) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Register'), get_option('blogname')), $message);
if ( empty($plaintext_pass) )
return;
$message = sprintf(__('Username: %s'), $user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
$message .= get_option('siteurl') . "/wp-login.php\r\n";
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);
}
endif;
?>