WordPress 2.5+ ONLY. Enhance your Registration Page. Add Custom Logo, Password Field, Invitation Codes, Disclaimer, Captcha Validation, Email Validation, User Moderation, Profile Fields and more. Author: Skullbit Version: 3.3 Author URI: http://www.skullbit.com LOCALIZATION Place your language file within this plugin directory and name it "regplus-{language}.mo" replace {language} with your language value from wp-config.php CHANGELOG v3.3 - July 23, 2006 * Updated conflict warning error to only appear on the RegPlus options page only. v3.2 - July 22, 2008 * Fixed Custom Field Checkbox saving issue * Additional field types available for Custom Fields. * Password Meter is now optional and text is editable within options page v3.1 - July 8, 2008 * Added Logo Removal Option * Updated Email Validation text after registering * Added User Sub-Panel for resending validation emails and automatic admin validation * Added User Moderation Ability - new registrations must be approved by admin before becoming active. * Fixed bad version control code v3.0.2 - June 23, 2008 * Updated Email notifications to use a filter to replace the From Name and Email address v3.0.1 - June 19, 2008 * Added more localization files * Added doccumentation for auto-complete queries * Fixed Admin notification email to now actually go to the administrator v3.0 - June 18, 2008 * Added localization to password strength text * Added stripslashes to missing areas * Added Login Redirect option for registration email url * Added Ability to populate registration fields using URL GET statements * Added Simple CAPTCHA Session check and warning if not enabled * Added ability to email all user data in notification emails v2.9 - June 10, 2008 * Fixed foreach error for custom invite codes * Custom logos can now be any size * Login fields are now hidden after registration if email verification is enabled. v2.8 - June 9, 2008 * Fixed Fatal Error on Options Page v2.7 - June 8, 2008 * Added full customization option to User Registration Email and Admin Email. * Added ability to disable Admin notification email. * Added style feature for required fields * Added Custom Logo upload for replacing WP Logo on register & login pages v2.6 - May 15, 2008 * Fixed error on ranpass function. v2.5 - May 14, 2008 * Fixed registration password email to work when user set password is disabled v2.4 - May 13, 2008 * Fixed localization issue * Added License Agreement & Privacy Policy plus user defined titles and agree text for these and the Disclaimer * Fixed Javascript error in IE v2.3 - May 12, 2008 * Added reCAPTCHA support * Fixed PHP short-code issue * Added option to not require Invite Code but still show it on registration page * Added ability to customize the registration email's From address, Subject and add your own message to the email body. v2.2 - April 27, 2008 * Fixed About Us Slashes from showing with apostrophes * Modified the Captcha code to hopefully fix some compatibility issues v2.1 - April 26, 2008 * Fixed Admin Registation Password issue * Added Dashboard Widget for showing invitation code tracking * Added Email Verification for ensuring legitimate addresses are registered. * Unvalidated registrations are unable to login and are deleted after a set grace period v2.0 - April 20, 2008 *Added Profile Fields to registration *Added multiple invite codes *Added Custom User Defined Fields with Profile integration *Added ability to ignore duplicate email registrations v1.2 - April 13, 2008 *Altered Options saving and retrievals for less database interactions *Added Disclaimer Feature *Allowed register fields to retain values on submission if there is an error. v1.1 - April 10, 2008 *Fixed Invitation Code from displaying when disabled. *Added Captcha Feature */ $rp = get_option( 'register_plus' ); if( $rp['dash_widget'] ) include_once('dash_widget.php'); if( !class_exists('RegisterPlusPlugin') ){ class RegisterPlusPlugin{ function RegisterPlusPlugin() { //constructor global $wp_version; //ACTIONS #Add Settings Panel add_action( 'admin_menu', array($this, 'AddPanel') ); #Update Settings on Save if( $_POST['action'] == 'reg_plus_update' ) add_action( 'init', array($this,'SaveSettings') ); #Enable jQuery on Settings panel if( $_GET['page'] == 'register-plus' ){ wp_enqueue_script('jquery'); add_action( 'admin_head', array($this, 'SettingsHead') ); } #Add Register Form Fields add_action( 'register_form', array($this, 'RegForm') ); #Add Register Page Javascript & CSS if($_GET['action'] == 'register') add_action( 'login_head', array($this, 'PassHead') ); #Add Custom Logo CSS to Login Page add_action( 'login_head', array($this, 'LogoHead') ); #Hide initial login fields when email verification is enabled add_action( 'login_head', array($this, 'HideLogin') ); #Save Default Settings add_action( 'init', array($this, 'DefaultSettings') ); #Profile add_action( 'show_user_profile', array($this, 'Add2Profile') ); add_action( 'edit_user_profile', array($this, 'Add2Profile') ); add_action( 'profile_update', array($this, 'SaveProfile') ); #Validate User add_action( 'login_form', array($this, 'ValidateUser') ); #Delete Invalid Users add_action( 'init', array($this, 'DeleteInvalidUsers') ); #Unverified Users Head Scripts add_action( 'admin_head', array($this, 'UnverifiedHead') ); #Admin Validate Users if( $_POST['verifyit'] ) add_action( 'init', array($this, 'AdminValidate') ); #Admin Resend VerificatioN Email if( $_POST['emailverifyit'] ) add_action( 'init', array($this, 'AdminEmailValidate') ); #Admin Delete Unverified User if( $_POST['vdeleteit'] ) add_action( 'init', array($this, 'AdminDeleteUnvalidated') ); //FILTERS #Check Register Form for Errors add_filter( 'registration_errors', array($this, 'RegErrors') ); //LOCALIZATION #Place your language file in the plugin folder and name it "regplus-{language}.mo" #replace {language} with your language value from wp-config.php load_plugin_textdomain( 'regplus', '/wp-content/plugins/register-plus' ); //VERSION CONTROL if( $wp_version < 2.5 ) add_action('admin_notices', array($this, 'version_warning')); } function version_warning(){ global $wp_version; echo "

".__('Register Plus is only compatible with WordPress v2.5 and up. You are currently using WordPress v.', 'regplus').$wp_version."

"; } function AddPanel(){ add_options_page( 'Register Plus', 'Register Plus', 10, 'register-plus', array($this, 'RegPlusSettings') ); $regplus = get_option('register_plus'); if( $regplus['email_verify'] || $regplus['admin_verify'] ) add_users_page( 'Unverified Users', 'Unverified Users', 10, 'unverified-users', array($this, 'Unverified') ); } function DefaultSettings () { $default = array( 'password' => '0', 'password_meter' => '0', 'short' => 'Too Short', 'bad' => 'Bad Password', 'good' => 'Good Password', 'strong' => 'Strong Password', 'code' => '0', 'codepass' => array('0'), 'captcha' => '0', 'disclaimer' => '0', 'disclaimer_title' => 'Disclaimer', 'disclaimer_content' => '', 'disclaimer_agree' => 'Accept the Disclaimer', 'license' => '0', 'license_title' => 'License Agreement', 'license_content' => '', 'license_agree' => 'Accept the License Agreement', 'privacy' => '0', 'privacy_title' => 'Privacy Policy', 'privacy_content' => '', 'privacy_agree' => 'Accept the Privacy Policy', 'email_exists' => '0', 'firstname' => '0', 'lastname' => '0', 'website' => '0', 'aim' => '0', 'yahoo' => '0', 'jabber' => '0', 'about' => '0', 'profile_req' => array('0'), 'require_style' => 'border:solid 1px #E6DB55;background-color:#FFFFE0;', 'dash_widget' => '0', 'email_verify' => '0', 'admin_verify' => '0', 'email_delete_grace' => '7', 'html' => '0', 'adminhtml' => '0', 'from' => get_option('admin_email'), 'fromname' => get_option('blogname'), 'subject' => sprintf(__('[%s] Your username and password', 'regplus'), get_option('blogname')), 'custom_msg' => '0', 'user_nl2br' => '0', 'msg' => " %blogname% Registration \r\n --------------------------- \r\n\r\n Here are your credentials: \r\n Username: %user_login% \r\n Password: %user_pass% \r\n Confirm Registration: %siteurl% \r\n\r\n Thank you for registering with %blogname%! \r\n", 'disable_admin' => '0', 'adminfrom' => get_option('admin_email'), 'adminfromname' => get_option('blogname'), 'adminsubject' => sprintf(__('[%s] New User Register', 'regplus'), get_option('blogname')), 'custom_adminmsg' => '0', 'admin_nl2br' => '0', 'adminmsg' => " New %blogname% Registration \r\n --------------------------- \r\n\r\n Username: %user_login% \r\n E-Mail: %user_email% \r\n", 'logo' => '', 'login_redirect' => get_option('siteurl') ); # 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') ){ #Set Defaults if no values exist add_option( 'register_plus', $default ); }else{ #Set Defaults if new value does not exist $regplus = get_option( 'register_plus' ); foreach( $default as $key => $val ){ if( !$regplus[$key] ){ $regplus[$key] = $val; $new = true; } } if( $new ) update_option( 'register_plus', $regplus ); } } function SaveSettings(){ check_admin_referer('regplus-update-options'); $update = get_option( 'register_plus' ); $update["password"] = $_POST['regplus_password']; $update["password_meter"] = $_POST['regplus_password_meter']; $update["short"] = $_POST['regplus_short']; $update["bad"] = $_POST['regplus_bad']; $update["good"] = $_POST['regplus_good']; $update["strong"] = $_POST['regplus_strong']; $update["code"] = $_POST['regplus_code']; if( $_POST['regplus_code'] ) { $update["codepass"] = $_POST['regplus_codepass']; foreach( $update["codepass"] as $k=>$v ){ $update["codepass"][$k] = strtolower($v); } $update["code_req"] = $_POST['regplus_code_req']; } $update["captcha"] = $_POST['regplus_captcha']; $update["disclaimer"] = $_POST['regplus_disclaimer']; $update["disclaimer_title"] = $_POST['regplus_disclaimer_title']; $update["disclaimer_content"] = $_POST['regplus_disclaimer_content']; $update["disclaimer_agree"] = $_POST['regplus_disclaimer_agree']; $update["license"] = $_POST['regplus_license']; $update["license_title"] = $_POST['regplus_license_title']; $update["license_content"] = $_POST['regplus_license_content']; $update["license_agree"] = $_POST['regplus_license_agree']; $update["privacy"] = $_POST['regplus_privacy']; $update["privacy_title"] = $_POST['regplus_privacy_title']; $update["privacy_content"] = $_POST['regplus_privacy_content']; $update["privacy_agree"] = $_POST['regplus_privacy_agree']; $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']; $update["require_style"] = $_POST['regplus_require_style']; $update["dash_widget"] = $_POST['regplus_dash_widget']; $update["admin_verify"] = $_POST['regplus_admin_verify']; $update["email_verify"] = $_POST['regplus_email_verify']; $update["email_verify_date"] = $_POST['regplus_email_verify_date']; $update["email_delete_grace"] = $_POST['regplus_email_delete_grace']; $update["reCAP_public_key"] = $_POST['regplus_reCAP_public_key']; $update["reCAP_private_key"] = $_POST['regplus_reCAP_private_key']; $update['html'] = $_POST['regplus_html']; $update['from'] = $_POST['regplus_from']; $update['fromname'] = $_POST['regplus_fromname']; $update['subject'] = $_POST['regplus_subject']; $update['custom_msg'] = $_POST['regplus_custom_msg']; $update['user_nl2br'] = $_POST['regplus_user_nl2br']; $update['msg'] = $_POST['regplus_msg']; $update['disable_admin'] = $_POST['regplus_disable_admin']; $update['adminhtml'] = $_POST['regplus_adminhtml']; $update['adminfrom'] = $_POST['regplus_adminfrom']; $update['adminfromname'] = $_POST['regplus_adminfromname']; $update['adminsubject'] = $_POST['regplus_adminsubject']; $update['custom_adminmsg'] = $_POST['regplus_custom_adminmsg']; $update['admin_nl2br'] = $_POST['regplus_admin_nl2br']; $update['adminmsg'] = $_POST['regplus_adminmsg']; $update['login_redirect'] = $_POST['regplus_login_redirect']; if( $_FILES['regplus_logo']['name'] ) $update['logo'] = $this->UploadLogo(); else if( $_POST['remove_logo'] ) $update['logo'] = ''; 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], 'fieldtype' => $_POST['fieldtype'][$k], 'extraoptions' => $_POST['extraoptions'][$k] ); } } update_option( 'register_plus_custom', $custom ); update_option( 'register_plus', $update ); $_POST['notice'] = __('Settings Saved', 'regplus'); } function UploadLogo(){ $upload_dir = ABSPATH . get_option('upload_path'); $upload_file = trailingslashit($upload_dir) . basename($_FILES['regplus_logo']['name']); //echo $upload_file; if( !is_dir($upload_dir) ) wp_upload_dir(); if( move_uploaded_file($_FILES['regplus_logo']['tmp_name'], $upload_file) ){ chmod($upload_file, 0777); $logo = $_FILES['regplus_logo']['name']; return trailingslashit( get_option('siteurl') ) . 'wp-content/uploads/' . $logo; }else{ return false; } } function SettingsHead(){ $regplus = get_option( 'register_plus' ); ?> "; } function AdminValidate(){ global $wpdb; $regplus = get_option('register_plus'); check_admin_referer('regplus-unverified'); $valid = $_POST['vusers']; foreach( $valid as $user_id ){ if ( $user_id ) { if( $regplus['email_verify'] ){ $login = get_usermeta($user_id, 'email_verify_user'); $wpdb->query( "UPDATE $wpdb->users SET user_login = '$login' WHERE ID = '$user_id'" ); delete_usermeta($user_id, 'email_verify_user'); delete_usermeta($user_id, 'email_verify'); delete_usermeta($user_id, 'email_verify_date'); }else if( $regplus['admin_verify'] ){ $login = get_usermeta($user_id, 'admin_verify_user'); $wpdb->query( "UPDATE $wpdb->users SET user_login = '$login' WHERE ID = '$user_id'" ); delete_usermeta($user_id, 'admin_verify_user'); } $this->VerifyNotification($user_id); } } $_POST['notice'] = __("Users Verified","regplus"); } function AdminDeleteUnvalidated() { global $wpdb; $regplus = get_option('register_plus'); check_admin_referer('regplus-unverified'); $delete = $_POST['vusers']; include_once( ABSPATH . 'wp-admin/includes/user.php' ); foreach( $delete as $user_id ){ if ( $user_id ) { wp_delete_user($user_id); } } $_POST['notice'] = __("Users Deleted","regplus"); } function AdminEmailValidate(){ global $wpdb; check_admin_referer('regplus-unverified'); $valid = $_POST['vusers']; foreach( $valid as $user_id ){ $code = get_usermeta($user_id, 'email_verify'); $user_login = get_usermeta($user_id, 'email_verify_user'); $user_email = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE ID='$user_id'"); $email_code = '?regplus_verification=' . $code; $prelink = __('Verification URL: ', 'regplus'); $message = sprintf(__('Username: %s', 'regplus'), $user_login) . "\r\n"; //$message .= sprintf(__('Password: %s', 'regplus'), $plaintext_pass) . "\r\n"; $message .= $prelink . get_option('siteurl') . "/wp-login.php" . $email_code . "\r\n"; $message .= $notice; add_filter('wp_mail_from', array($register_plus, 'userfrom')); add_filter('wp_mail_from_name', array($register_plus, 'userfromname')); wp_mail($user_email, sprintf(__('[%s] Verify Account Link', 'regplus'), get_option('blogname')), $message); } $_POST['notice'] = __("Verification Emails have been re-sent", "regplus"); } function VerifyNotification($user_id){ global $wpdb; $regplus = get_option('register_plus'); $user = $wpdb->get_row("SELECT user_login, user_email FROM $wpdb->users WHERE ID='$user_id'"); $message = __('Your account has now been activated by an administrator.') . "\r\n"; $message .= sprintf(__('Username: %s', 'regplus'), $user->user_login) . "\r\n"; $message .= $prelink . get_option('siteurl') . "/wp-login.php" . $email_code . "\r\n"; add_filter('wp_mail_from', array($register_plus, 'userfrom')); add_filter('wp_mail_from_name', array($register_plus, 'userfromname')); wp_mail($user->user_email, sprintf(__('[%s] User Account Activated', 'regplus'), get_option('blogname')), $message); } function Unverified(){ global $wpdb; if( $_POST['notice'] ) echo '

' . $_POST['notice'] . '.

'; $unverified = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_login LIKE '%unverified__%'"); $regplus = get_option('register_plus'); ?>

   


ID); $roles = $user_object->roles; $role = array_shift($roles); if( $regplus['email_verify'] ) $user_login = get_usermeta($un->ID, 'email_verify_user'); else if( $regplus['admin_verify'] ) $user_login = get_usermeta($un->ID, 'admin_verify_user'); ?>
user_login;?> user_email;?>

' . $_POST['notice'] . '.

'; if( !is_array($regplus['profile_req']) ) $regplus['profile_req'] = array(); if( is_array($regplus['codepass']) ){ foreach( $regplus['codepass'] as $code ){ $codes .= '
  ' . __( ' . __(
'; } } $types = ''; $extras = '
'; if( is_array($regplus_custom) ){ foreach( $regplus_custom as $k => $v ) { $types = ''; } ?>


'.$op.' '; } ?>


'; } else if( $v['fieldtype'] == 'radio' ){ $ops = explode(',',$v['extraoptions']); foreach( $ops as $op ){ $radio .= ' '; } ?>


'; } else if( $v['fieldtype'] == 'textarea' ){ ?>






'; echo rp_recaptcha_get_html($publickey); echo ' 
'; } } function Label_ID($label){ $id = str_replace(' ', '_', $label); $id = strtolower($id); $id = sanitize_user($id, true); return $id; } # Add Javascript & CSS needed function PassHead(){ $regplus = get_option( 'register_plus' ); if( isset( $_GET['user_login'] ) ) $user_login = $_GET['user_login']; if( isset( $_GET['user_email'] ) ) $user_email = $_GET['user_email']; if ( $regplus['password'] ){ ?> 0){ $top = '

' . __('Additional Information', 'regplus') . '

'; $bottom = '
'; } echo $top; if (!empty($regplus_custom)) { foreach( $regplus_custom as $k=>$v ){ if( $v['profile'] ){ $id = $this->Label_ID($v['label']); $value = get_usermeta( $user_ID, $id ); $extraops = explode(',', $v['extraoptions']); switch( $v['fieldtype'] ){ case "text" : $outfield = ''; break; case "hidden" : $outfield = ''; break; case "select" : $outfield = ''; break; case "textarea" : $outfield = ''; break; case "checkbox" : $outfield = ''; $valarr = explode(', ', $value); foreach( $extraops as $op ){ $outfield .= '