diff --git a/change_log.txt b/change_log.txt index 5edec9c..67e790f 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,43 @@ +----------------------------------------------------------- +Version 2.0 + - Added support for updating file upload fields mapped to BuddyPress image fields (available via BP add-on). + - Added additional logging statements. + - Updated pending activation so that it doesn't rely on the password being in the entry. + - Updated POT file. + - Updated plugin updated method so that it takes advantage of proxy manager to get around the blacklisted IP issue. + - Fixed issue where pending activations were not sorted correctly. + - Fixed update feeds in Gravity Forms 1.9. + - Fixed issue where BuddyPress field visibility was ignored. + - Fixed warning message on plugin's page. + - Fixed notice when 'create_site' feed meta was not set. + - Fixed issue where "Simple" type Name fields did not map to user meta correctly. + - Fixed issue where data pulled from BuddyPress was not always correctly matched since the HTML entities were already encoded. + - Fixed issue whith PayPal integration where users were not getting created when payment was manually being marked as Approved on the entry detail page. + - Fixed notice thrown when updating BuddyPress Last Activity meta; updated to use new version. + - Fixed issue where the upgrade class wasn't included which caused ManageWP to not work with add-on. + - Fixed notices thrown in the downgrade_paypal_user function. + +----------------------------------------------------------- +Version 1.9 + - Added 'gform_user_registration_new_site_meta' filter for filtering the meta used to create a new site + add_filter( 'gform_user_registration_new_site_meta', 'add_blog_template', 10, 6 ); + function add_blog_template( $site_meta, $form, $entry, $feed, $user_id, $is_update_feed ) { + $signup_meta['blog_template'] = 1; + return $signup_meta; + } + - Added "Preserve current role" option for "Current Site Role" setting + - Added 'gform_user_registration_signup_meta' filter for filtering the signup meta + add_filter( 'gform_user_registration_signup_meta', 'add_blog_template', 10, 4 ); + function add_blog_template( $signup_meta, $form, $entry, $feed ) { + $signup_meta['blog_template'] = 1; + return $signup_meta; + } + - Added current user object to wpmu_validate_blog_signup() call to allow registering sites with the same name as the current user + - Fixed the functions used by the mwp_premium_update_notification and mwp_premium_perform_update hooks so that the new_version element in the array returns the add-on's version instead of Gravity Forms' + - Fixed issue where signups table on single site installs failed to update correctly when promoting site to multisite + - Fixed issue where activation emails were sent even though manual activation was enabled + - Fixed strict notice for Non-static method GFUserSignups::install_signups() + ----------------------------------------------------------- Version 1.8 - Added more debug statements for logging. diff --git a/data.php b/data.php index cb725b0..d9dfcc0 100644 --- a/data.php +++ b/data.php @@ -210,6 +210,7 @@ public static function insert_buddypress_data($bp_rows) { foreach($bp_rows as $bp_row) { $success = xprofile_set_field_data($bp_row['field_id'], $bp_row['user_id'], $bp_row['value']); + xprofile_set_field_visibility_level( $bp_row['field_id'], $bp_row['user_id'], $bp_row['field']->default_visibility ); } } diff --git a/includes/pending_activations.php b/includes/pending_activations.php index 6fe2bf6..50b9de4 100644 --- a/includes/pending_activations.php +++ b/includes/pending_activations.php @@ -123,7 +123,7 @@ public static function get_pending_activations($form_id, $args = array()) { $where[] = "s.active = 0"; $where = 'WHERE ' . implode(' AND ', $where); - $order = $wpdb->prepare("ORDER BY %s %s", $order_by, $order); + $order = "ORDER BY {$order_by} {$order}"; $offset = ($page * $per_page) - $per_page; $limit_offset = $get_total ? '' : "LIMIT $per_page OFFSET $offset"; $method = $get_total ? 'get_var' : 'get_results'; diff --git a/includes/signups.php b/includes/signups.php index ac7244b..5c92b2f 100644 --- a/includes/signups.php +++ b/includes/signups.php @@ -3,29 +3,58 @@ class GFUserSignups { public static function create_signups_table() { - require_once(ABSPATH . "wp-admin/includes/upgrade.php"); - - global $wpdb, $charset_collate; + global $wpdb; self::add_signups_to_wpdb(); - $ms_queries = "CREATE TABLE $wpdb->signups ( - domain varchar(200) NOT NULL default '', - path varchar(100) NOT NULL default '', - title longtext NOT NULL, - user_login varchar(60) NOT NULL default '', - user_email varchar(100) NOT NULL default '', - registered datetime NOT NULL default '0000-00-00 00:00:00', - activated datetime NOT NULL default '0000-00-00 00:00:00', - active tinyint(1) NOT NULL default '0', - activation_key varchar(50) NOT NULL default '', - meta longtext, - KEY activation_key (activation_key), - KEY domain (domain) - ) $charset_collate;"; - - // now create table - dbDelta($ms_queries); + $table_exists = (bool) $wpdb->get_results( "DESCRIBE {$wpdb->signups};" ); + + // Upgrade verions prior to 3.7 + if ( $table_exists ) { + + $column_exists = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->signups} LIKE 'signup_id'" ); + + if( empty( $column_exists ) ) { + + // New primary key for signups. + $wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" ); + $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" ); + + } + + } + + self::install_signups(); + + } + + private static function install_signups() { + global $wpdb; + + // Signups is not there and we need it so let's create it + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); + + // Use WP's core CREATE TABLE query + $create_queries = wp_get_db_schema( 'ms_global' ); + if ( ! is_array( $create_queries ) ) { + $create_queries = explode( ';', $create_queries ); + $create_queries = array_filter( $create_queries ); + } + + // Filter out all the queries except wp_signups + foreach ( $create_queries as $key => $query ) { + if ( preg_match( "|CREATE TABLE ([^ ]*)|", $query, $matches ) ) { + if ( trim( $matches[1], '`' ) !== $wpdb->signups ) { + unset( $create_queries[ $key ] ); + } + } + } + + // Run WordPress's database upgrader + if ( ! empty( $create_queries ) ) { + dbDelta( $create_queries ); + } + } /** @@ -33,7 +62,7 @@ public static function create_signups_table() { */ private static function add_signups_to_wpdb() { global $wpdb; - $wpdb->signups = $wpdb->prefix . 'signups'; + $wpdb->signups = $wpdb->base_prefix . 'signups'; } public static function prep_signups_functionality() { @@ -55,6 +84,10 @@ public static function prep_signups_functionality() { add_filter( 'wpmu_signup_user_notification_email', array( 'GFUserSignups', 'modify_signup_user_notification_message' ), 10, 4 ); add_filter( 'wpmu_signup_blog_notification_email', array( 'GFUserSignups', 'modify_signup_blog_notification_message' ), 10, 7 ); + // disable activation email for manual activation feeds + add_filter( 'wpmu_signup_user_notification', array( 'GFUserSignups', 'maybe_suppress_signup_user_notification' ), 10, 3 ); + add_filter( 'wpmu_signup_blog_notification', array( 'GFUserSignups', 'maybe_suppress_signup_blog_notification' ), 10, 6 ); + add_filter( 'wpmu_signup_user_notification', array( __class__, 'add_site_name_filter' ) ); add_filter( 'wpmu_signup_user_notification_subject', array( __class__, 'remove_site_name_filter' ) ); @@ -66,12 +99,23 @@ public static function prep_signups_functionality() { } - public static function modify_signup_user_notification_message($message, $user, $user_email, $key) { + public static function maybe_suppress_signup_user_notification( $user, $user_email, $key ) { + return self::is_manual_activation( $key ) ? false : $user; + } + public function maybe_suppress_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key ) { + return self::is_manual_activation( $key ) ? false : $user; + } + + public static function is_manual_activation( $key ) { $signup = GFSignup::get( $key ); + return ! is_wp_error( $signup ) && $signup->get_activation_type() == 'manual'; + } + + public static function modify_signup_user_notification_message($message, $user, $user_email, $key) { - // if no signup or config is set for manual activation, return false preventing signup notification from being sent to user - if( is_wp_error( $signup ) || $signup->get_activation_type() == 'manual' ) + // don't send activation email for manual activations + if( self::is_manual_activation( $key ) ) return false; $url = add_query_arg(array('page' => 'gf_activation', 'key' => $key), get_site_url() . '/' ); @@ -87,10 +131,8 @@ public static function modify_signup_user_notification_message($message, $user, public static function modify_signup_blog_notification_message($message, $domain, $path, $title, $user, $user_email, $key) { - $signup = GFSignup::get( $key ); - - // if no signup or config is set for manual activation, return false preventing signup notification from being sent to user - if( is_wp_error( $signup ) || $signup->get_activation_type() == 'manual' ) + // don't send activation email for manual activations + if( self::is_manual_activation( $key ) ) return false; $url = add_query_arg(array('page' => 'gf_activation', 'key' => $key), get_site_url()); @@ -158,8 +200,9 @@ public static function activate_signup($key) { // unbind site creation from gform_user_registered hook, run it manually below if(is_multisite()) remove_action( 'gform_user_registered' , array( 'GFUser', 'create_new_multisite' ) ); - - $user_data = GFUser::create_user( $signup->lead, $signup->form, $signup->config); + + GFUser::log_debug("Activating signup for username: {$signup->user_login} - entry: {$signup->lead["id"]}" ); + $user_data = GFUser::create_user( $signup->lead, $signup->form, $signup->config, GFUser::decrypt( $signup->meta['password'] ) ); $user_id = rgar($user_data, 'user_id'); if(!$user_id){ diff --git a/languages/gravityformsuserregistration.pot b/languages/gravityformsuserregistration.pot index 7c44d07..7f393cd 100644 --- a/languages/gravityformsuserregistration.pot +++ b/languages/gravityformsuserregistration.pot @@ -2,460 +2,726 @@ msgid "" msgstr "" "Project-Id-Version: Gravity Forms User Registration\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-07-16 05:47-0500\n" -"PO-Revision-Date: 2011-07-16 05:53-0500\n" -"Last-Translator: David Smith \n" -"Language-Team: Rocket Genius \n" +"POT-Creation-Date: 2014-10-22 13:52-0500\n" +"PO-Revision-Date: 2014-10-22 13:54-0500\n" +"Last-Translator: Dana Cobb \n" +"Language-Team: Rocketgenius \n" +"Language: en_US\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Poedit-KeywordsList: _;gettext;gettext_noop;_e;__\n" +"X-Poedit-KeywordsList: _e;__\n" "X-Poedit-Basepath: .\n" -"X-Poedit-SearchPath-0: C:\\xampp\\htdocs\\wp-content\\plugins\\gravityformsuserregistration\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.6.10\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-SearchPath-0: ..\n" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/plugin-upgrade.php:56 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:166 +#: ../includes/activate.php:37 +msgid "Activation Key Required" +msgstr "" + +#: ../includes/activate.php:40 +msgid "Activation Key:" +msgstr "" + +#: ../includes/activate.php:56 ../includes/activate.php:76 +msgid "Your account is now active!" +msgstr "" + +#: ../includes/activate.php:60 +#, php-format +msgid "" +"Your account has been activated. You may now log in to " +"the site using your chosen username of “%2$s”. Please check your " +"email inbox at %3$s for your password and login instructions. If you do not " +"receive an email, please check your junk or spam folder. If you still do not " +"receive an email within an hour, you can reset your " +"password." +msgstr "" + +#: ../includes/activate.php:62 +#, php-format +msgid "" +"Your site at %2$s is active. You may now log in to your " +"site using your chosen username of “%3$s”. Please check your " +"email inbox at %4$s for your password and login instructions. If you do not " +"receive an email, please check your junk or spam folder. If you still do not " +"receive an email within an hour, you can reset your " +"password." +msgstr "" + +#: ../includes/activate.php:67 +msgid "An error occurred during the activation" +msgstr "" + +#: ../includes/activate.php:79 +msgid "Username:" +msgstr "" + +#: ../includes/activate.php:80 +msgid "Password:" +msgstr "" + +#: ../includes/activate.php:84 +#, php-format +msgid "" +"Your account is now activated. View your site or Log in" +msgstr "" + +#: ../includes/activate.php:86 +#, php-format +msgid "" +"Your account is now activated. Log in or go back to the " +"homepage." +msgstr "" + +#: ../includes/pending_activations.php:26 ../userregistration.php:436 +#: ../userregistration.php:1552 +msgid "Pending Activations" +msgstr "" + +#: ../includes/pending_activations.php:29 +#, php-format +msgid "Pending Activations for %s" +msgstr "" + +#: ../includes/pending_activations.php:40 +msgid "Select a Form" +msgstr "" + +#: ../includes/pending_activations.php:41 +msgid "View All Pending Activations" +msgstr "" + +#: ../includes/pending_activations.php:42 +msgid "Forms" +msgstr "" + +#: ../includes/pending_activations.php:290 +msgid "Activate this sign up? " +msgstr "" + +#: ../includes/pending_activations.php:290 +msgid "\\'Cancel\\' to stop, \\'OK\\' to activate." +msgstr "" + +#: ../includes/pending_activations.php:296 +msgid "Delete this sign up? " +msgstr "" + +#: ../includes/pending_activations.php:296 ../userregistration.php:395 +#: ../userregistration.php:440 +msgid "\\'Cancel\\' to stop, \\'OK\\' to delete." +msgstr "" + +#: ../includes/pending_activations.php:309 +msgid "Activate" +msgstr "" + +#: ../includes/pending_activations.php:310 ../userregistration.php:392 +#: ../userregistration.php:440 ../userregistration.php:2947 +msgid "Delete" +msgstr "" + +#: ../includes/signups.php:193 +msgid "That username is already activated." +msgstr "" + +#: ../includes/signups.php:197 ../userregistration.php:2640 +msgid "Sorry, that email address is already used!" +msgstr "" + +#: ../includes/signups.php:208 +msgid "Could not create user" +msgstr "" + +#: ../includes/signups.php:264 +msgid "Invalid activation key." +msgstr "" + +#: ../includes/signups.php:267 +msgid "The user is already active." +msgstr "" + +#: ../plugin-upgrade.php:50 ../userregistration.php:230 #, php-format msgid "View version %s Details" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/plugin-upgrade.php:75 +#: ../plugin-upgrade.php:69 #, php-format msgid "Oops!! Something went wrong.%sPlease try again or %scontact us%s." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:159 +#: ../userregistration.php:223 msgid "Gravity Forms " msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:166 -msgid "There is a new version of Gravity Forms User Registration Add-On available." +#: ../userregistration.php:230 +msgid "" +"There is a new version of Gravity Forms User Registration Add-On available." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:167 +#: ../userregistration.php:231 #, php-format -msgid "%sRegister%s your copy of Gravity Forms to receive access to automatic upgrades and support. Need a license key? %sPurchase one now%s." +msgid "" +"%sRegister%s your copy of Gravity Forms to receive access to automatic " +"upgrades and support. Need a license key? %sPurchase one now%s." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:207 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:233 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:285 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:522 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1989 +#: ../userregistration.php:273 ../userregistration.php:316 +#: ../userregistration.php:2908 msgid "User Registration" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:223 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:625 +#: ../userregistration.php:302 ../userregistration.php:791 msgid "Gravity Form" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:223 -msgid "Select the Gravity Form you would like to use to register users for your WordPress website." +#: ../userregistration.php:302 +msgid "" +"Select the Gravity Form you would like to use to register users for your " +"WordPress website." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:224 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:660 +#: ../userregistration.php:303 ../userregistration.php:405 +#: ../userregistration.php:414 ../userregistration.php:777 +msgid "Action" +msgstr "" + +#: ../userregistration.php:303 +msgid "" +"Select the type of feed you would like to create. \"Create\" feeds will " +"create a new user. \"Update\" feeds will update users." +msgstr "" + +#: ../userregistration.php:304 ../userregistration.php:811 msgid "Username" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:224 +#: ../userregistration.php:304 msgid "Select the form field that should be used for the user's username." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:225 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:665 +#: ../userregistration.php:305 ../userregistration.php:816 msgid "First Name" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:225 +#: ../userregistration.php:305 msgid "Select the form field that should be used for the user's first name." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:226 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:670 +#: ../userregistration.php:306 ../userregistration.php:821 msgid "Last Name" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:226 +#: ../userregistration.php:306 msgid "Select the form field that should be used for the user's last name." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:227 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:675 +#: ../userregistration.php:307 ../userregistration.php:827 +msgid "Display Name" +msgstr "" + +#: ../userregistration.php:307 +msgid "Select how the user's name should be displayed publicly." +msgstr "" + +#: ../userregistration.php:308 ../userregistration.php:849 msgid "Email Address" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:227 +#: ../userregistration.php:308 msgid "Select the form field that should be used for the user's email address." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:228 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:680 +#: ../userregistration.php:309 ../userregistration.php:854 msgid "Password" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:228 +#: ../userregistration.php:309 msgid "Select the form field that should be used for the user's password." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:229 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:689 +#: ../userregistration.php:310 ../userregistration.php:860 msgid "Role" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:229 +#: ../userregistration.php:310 msgid "Select the role the user should be assigned." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:230 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:716 +#: ../userregistration.php:311 ../userregistration.php:887 msgid "Send Email?" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:230 -msgid "Specify whether to send the password to the new user by email. Enabled by default." +#: ../userregistration.php:311 +msgid "" +"Specify whether to send the password to the new user by email. Enabled by default." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:231 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:723 +#: ../userregistration.php:312 ../userregistration.php:893 msgid "Set As Post Author" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:231 -msgid "When a form submission creates a post and registers a user, set the new user as the post author. Enabled by default." +#: ../userregistration.php:312 +msgid "" +"When a form submission creates a post and registers a user, set the new user " +"as the post author. Enabled by default." +msgstr "" + +#: ../userregistration.php:313 ../userregistration.php:903 +msgid "User Activation" +msgstr "" + +#: ../userregistration.php:313 +msgid "" +"Send users an email with an activation link. Users are only registered once " +"they have activated their accounts." +msgstr "" + +#: ../userregistration.php:314 +msgid "User Activation Type" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:232 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:730 +#: ../userregistration.php:314 +msgid "" +"By Email: Send the user an email with an activation link." +"
Manually: Activate each user manually from the Pending Activations page." +msgstr "" + +#: ../userregistration.php:315 ../userregistration.php:928 msgid "Registration Condition" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:232 -msgid "When the registration condition is enabled, form submissions will only register the user when the condition is met. When disabled the user will not be registered." +#: ../userregistration.php:315 +msgid "" +"When the registration condition is enabled, form submissions will only " +"register the user when the condition is met. When disabled the user will not " +"be registered." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:233 -msgid "The selected form also has a User Registration feed. These options allow you to specify how you would like the PayPal and User Registration Add-ons to work together." +#: ../userregistration.php:316 +msgid "" +"The selected form also has a User Registration feed. These options allow you " +"to specify how you would like the PayPal and User Registration Add-ons to " +"work together." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:234 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1436 +#: ../userregistration.php:317 ../userregistration.php:1902 msgid "Create Site" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:234 -msgid "When WordPress Multisite is enabled, checking this option will enable the creation of a new site on the network when a new user registers." +#: ../userregistration.php:317 +msgid "" +"When WordPress Multisite is enabled, checking this option will enable the " +"creation of a new site on the network when a new user registers." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:235 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1444 +#: ../userregistration.php:318 ../userregistration.php:1910 msgid "Site Address" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:235 +#: ../userregistration.php:318 msgid "Select the form field that should be used for the site address." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:236 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1449 +#: ../userregistration.php:319 ../userregistration.php:1915 msgid "Site Title" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:236 +#: ../userregistration.php:319 msgid "Select the form field that should be used for the site title." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:256 +#: ../userregistration.php:320 ../userregistration.php:1921 +msgid "Site Role" +msgstr "" + +#: ../userregistration.php:320 +msgid "Select role the user should be assigned on the newly created site." +msgstr "" + +#: ../userregistration.php:321 ../userregistration.php:1932 +msgid "Current Site Role" +msgstr "" + +#: ../userregistration.php:321 +msgid "" +"Select role the user should be assigned on the site they registered from. " +"This option overrides the \"Role\" option under User Settings." +msgstr "" + +#: ../userregistration.php:346 #, php-format -msgid "User Registration Add-On requires Gravity Forms %s. Upgrade automatically on the %sPlugin page%s." +msgid "" +"User Registration Add-On requires Gravity Forms %s. Upgrade automatically on " +"the %sPlugin page%s." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:268 +#: ../userregistration.php:358 msgid "Feed deleted." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:279 +#: ../userregistration.php:369 msgid "Feeds deleted." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:286 +#: ../userregistration.php:378 msgid "User Registration Forms" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:287 -msgid "Add New" -msgstr "" - -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:297 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:299 +#: ../userregistration.php:389 ../userregistration.php:391 msgid "Bulk action" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:300 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:342 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2028 -msgid "Delete" -msgstr "" - -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:303 +#: ../userregistration.php:395 msgid "Apply" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:303 +#: ../userregistration.php:395 msgid "Delete selected feeds? " msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:303 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:342 -msgid "\\'Cancel\\' to stop, \\'OK\\' to delete." -msgstr "" - -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:312 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:320 +#: ../userregistration.php:404 ../userregistration.php:413 msgid "Form" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:333 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:380 +#: ../userregistration.php:427 ../userregistration.php:484 msgid "Active" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:333 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:376 +#: ../userregistration.php:427 ../userregistration.php:480 msgid "Inactive" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:335 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:338 +#: ../userregistration.php:429 ../userregistration.php:432 msgid "Edit" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:342 +#: ../userregistration.php:440 msgid "Delete this feed? " msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:354 +#: ../userregistration.php:447 ../userregistration.php:964 +msgid "Update" +msgstr "" + +#: ../userregistration.php:447 +msgid "Create" +msgstr "" + +#: ../userregistration.php:458 #, php-format -msgid "You don't have any User Registration feeds configured. Let's go %screate one%s!" +msgid "" +"You don't have any User Registration feeds configured. Let's go %screate one" +"%s!" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:391 +#: ../userregistration.php:495 msgid "Ajax error while updating feed" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:412 +#: ../userregistration.php:516 #, php-format -msgid "Gravity Forms User Registration Add-On has been successfully uninstalled. It can be re-activated from the %splugins page%s." +msgid "" +"Gravity Forms User Registration Add-On has been successfully uninstalled. It " +"can be re-activated from the %splugins page%s." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:433 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:523 +#: ../userregistration.php:537 ../userregistration.php:646 msgid "User Registration Settings" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:437 +#: ../userregistration.php:541 msgid "Custom Registration Page" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:440 +#: ../userregistration.php:544 msgid "Enable Custom Registration Page" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:459 +#: ../userregistration.php:563 msgid "Save Settings" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:467 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:470 +#: ../userregistration.php:571 msgid "Uninstall User Registration Add-On" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:468 -msgid "Warning! This operation deletes ALL User Registration Feeds." +#: ../userregistration.php:575 +msgid "Warning! This operation deletes ALL user registration feeds." +msgstr "" + +#: ../userregistration.php:575 +msgid "" +"If you continue, you will not be able to recover any User Registration data." +msgstr "" + +#: ../userregistration.php:578 +msgid "" +"Warning! ALL settings will be deleted. This cannot be undone. \\'OK\\' to " +"delete, \\'Cancel\\' to stop" +msgstr "" + +#: ../userregistration.php:716 +msgid "You must map the \"Email Address\" setting to a field." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:470 -msgid "Warning! ALL User Registration Feeds will be deleted. This cannot be undone. \\'OK\\' to delete, \\'Cancel\\' to stop" +#: ../userregistration.php:719 +msgid "You must map the \"Username\" setting to a field." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:581 +#: ../userregistration.php:729 #, php-format msgid "Feed Updated. %sback to list%s" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:601 -msgid "Auto Generate Password" +#: ../userregistration.php:753 ../userregistration.php:1100 +msgid "Preserve current password" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:618 -msgid "Your Registration Feed could not be saved. Please update the errors below and re-save your feed." +#: ../userregistration.php:753 ../userregistration.php:1100 +msgid "Auto Generate Password" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:628 -msgid "Select a form" +#: ../userregistration.php:761 +msgid "Oops! There were some issues with your feed." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:648 -msgid "The form selected does not have any Email fields. Please add an Email field to the form and try again." +#: ../userregistration.php:779 +msgid "Select an Action" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:660 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:675 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1444 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1449 +#: ../userregistration.php:811 ../userregistration.php:849 +#: ../userregistration.php:1910 ../userregistration.php:1915 +#: ../userregistration.php:1922 ../userregistration.php:1933 msgid "required" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:719 +#: ../userregistration.php:889 msgid "Send this password to the new user by email." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:726 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:734 +#: ../userregistration.php:895 ../userregistration.php:932 msgid "Enable" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:739 +#: ../userregistration.php:908 +msgid "Enable user activation." +msgstr "" + +#: ../userregistration.php:909 +msgid "Enable user activation" +msgstr "" + +#: ../userregistration.php:937 msgid "Register the user if " msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:745 +#: ../userregistration.php:941 msgid "is" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:746 +#: ../userregistration.php:942 msgid "is not" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:753 -msgid "To create a registration condition, your form must have a drop down, checkbox or multiple choice field" +#: ../userregistration.php:943 +msgid "greater than" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:764 -msgid "Save" +#: ../userregistration.php:944 +msgid "less than" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:764 -msgid "Update" +#: ../userregistration.php:945 +msgid "contains" +msgstr "" + +#: ../userregistration.php:946 +msgid "starts with" +msgstr "" + +#: ../userregistration.php:947 +msgid "ends with" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:765 +#: ../userregistration.php:953 +msgid "" +"To create a registration condition, your form must have a field supported by " +"conditional logic." +msgstr "" + +#: ../userregistration.php:964 +msgid "Save" +msgstr "" + +#: ../userregistration.php:965 msgid "Cancel" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:813 -msgid "Ajax error while selecting a form" +#: ../userregistration.php:1035 +msgid "There was an error getting the available forms" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:889 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1298 +#: ../userregistration.php:1080 +msgid "" +"This field does not have any Email fields. Please add an " +"Email field and try again." +msgstr "" + +#: ../userregistration.php:1114 ../userregistration.php:3361 +msgid "— Preserve current role —" +msgstr "" + +#: ../userregistration.php:1183 ../userregistration.php:1707 msgid "add another rule" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:891 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1300 +#: ../userregistration.php:1185 ../userregistration.php:1709 msgid "remove this rule" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:935 +#: ../userregistration.php:1244 msgid "Enter Meta Name" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1433 -msgid "Multisite Options" +#: ../userregistration.php:1462 +msgid "Enter value" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1438 -msgid "Create new site when a user registers." +#: ../userregistration.php:1549 +msgid "User Registration Feeds" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1579 -#, php-format -msgid "" -"New site created by %1s\n" -"\n" -"Address: http://%2s\n" -"Name: %3s" +#: ../userregistration.php:1550 +msgid "Add New" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1580 -#, php-format -msgid "[%s] New Site Created" +#: ../userregistration.php:1554 +msgid "Edit Feed" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1778 -msgid "This username is already registered" +#: ../userregistration.php:1554 +msgid "New Feed" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1781 -msgid "The username can only contain alphanumeric characters (A-Z, 0-9), underscores, dashes and spaces" +#: ../userregistration.php:1639 +msgid "BuddyPress Profile" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1784 -msgid "The username can only contain alphanumeric characters (A-Z, 0-9), underscores and dashes" +#: ../userregistration.php:1899 +msgid "Network Options" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1787 -msgid "The username can not be empty" +#: ../userregistration.php:1904 +msgid "Create new site when a user registers." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1793 +#: ../userregistration.php:2615 +msgid "Passwords may not contain the character \"\\\"" +msgstr "" + +#: ../userregistration.php:2644 +msgid "" +"That email address has already been used. Please check your inbox for an " +"activation email. It will become available in a couple of days if you do " +"nothing." +msgstr "" + +#: ../userregistration.php:2685 ../userregistration.php:2687 msgid "This email address is already registered" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1796 +#: ../userregistration.php:2691 msgid "The email address can not be empty" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:1800 -msgid "Passwords may not contain the character \"\\\"" +#: ../userregistration.php:2699 +msgid "This username is already registered" +msgstr "" + +#: ../userregistration.php:2702 +msgid "" +"The username can only contain alphanumeric characters (A-Z, 0-9), " +"underscores, dashes and spaces" +msgstr "" + +#: ../userregistration.php:2705 +msgid "" +"The username can only contain alphanumeric characters (A-Z, 0-9), " +"underscores and dashes" +msgstr "" + +#: ../userregistration.php:2708 +msgid "The username can not be empty" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2000 +#: ../userregistration.php:2919 msgid "Register user only when a payment is received." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2002 +#: ../userregistration.php:2921 msgid "Register user and create site only when a payment is received." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2010 +#: ../userregistration.php:2929 msgid "Update user when subscription is cancelled." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2016 +#: ../userregistration.php:2935 #, php-format msgid "Set User as %s" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2025 +#: ../userregistration.php:2944 msgid "Update site when subscription is cancelled." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2028 +#: ../userregistration.php:2947 msgid "Deactivate" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2030 +#: ../userregistration.php:2949 #, php-format msgid "%s site" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2130 -msgid "You don't have adequate permission to uninstall the User Registration Add-On." +#: ../userregistration.php:3096 +msgid "" +"You don't have adequate permission to uninstall the User Registration Add-On." msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2176 -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2235 +#: ../userregistration.php:3147 ../userregistration.php:3207 msgid "Full" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2335 -msgid "Register" +#: ../userregistration.php:3368 +msgid "— No role for this site —" msgstr "" -#: C:\xampp\htdocs\wp-content\plugins\gravityformsuserregistration/userregistration.php:2343 -msgid "Site Admin" +#: ../userregistration.php:3706 +msgid "Oops! You need to be logged in to use this form." +msgstr "" + +#: ../userregistration.php:3745 +msgid "Select a form" msgstr "" +#: ../userregistration.php:3784 +msgid "Pending Activation:" +msgstr "" + +#: ../userregistration.php:3792 +msgid "Are you sure you want to activate this user?" +msgstr "" + +#: ../userregistration.php:3812 +msgid "User Activated Successfully" +msgstr "" diff --git a/plugin-upgrade.php b/plugin-upgrade.php index 0edf718..6e97370 100644 --- a/plugin-upgrade.php +++ b/plugin-upgrade.php @@ -91,8 +91,14 @@ public static function get_version_info($offering, $key, $version, $use_cache=tr 'User-Agent' => 'WordPress/' . get_bloginfo("version"), 'Referer' => get_bloginfo("url") ); - $url = GRAVITY_MANAGER_URL . "/version.php?" . self::get_remote_request_params($offering, $key, $version); - $raw_response = wp_remote_request($url, $options); + + if ( method_exists( 'GFCommon', 'post_to_manager' ) ){ + $raw_response = GFCommon::post_to_manager("version.php", self::get_remote_request_params($offering, $key, $version), $options); + } + else{ + $url = GRAVITY_MANAGER_URL . "/version.php?" . self::get_remote_request_params($offering, $key, $version); + $raw_response = wp_remote_request($url, $options); + } if ( is_wp_error( $raw_response ) || 200 != $raw_response['response']['code']){ $version_info = -1; diff --git a/userregistration.php b/userregistration.php index 6836374..3c0891d 100644 --- a/userregistration.php +++ b/userregistration.php @@ -3,7 +3,7 @@ Plugin Name: Gravity Forms User Registration Add-On Plugin URI: http://www.gravityforms.com Description: Allows WordPress users to be automatically created upon submitting a Gravity Form -Version: 1.8 +Version: 2.0 Author: rocketgenius Author URI: http://www.rocketgenius.com @@ -35,7 +35,7 @@ class GFUser { private static $path = "gravityformsuserregistration/userregistration.php"; private static $url = "http://www.gravityforms.com"; private static $slug = "gravityformsuserregistration"; - private static $version = "1.8"; + private static $version = "2.0"; private static $min_gravityforms_version = "1.7"; private static $supported_fields = array( "checkbox", "radio", "select", "text", "website", "textarea", "email", "hidden", "number", "phone", "multiselect", "post_title", "post_tags", "post_custom_field", "post_content", "post_excerpt" ); @@ -56,7 +56,7 @@ public static function init(){ if(!self::is_gravityforms_supported()) return; - + if(is_admin()){ //runs the setup when version changes @@ -85,6 +85,8 @@ public static function init(){ // process users from unspammed entries add_action("gform_update_status", array("GFUser", "gf_process_user"), 10, 3); + add_action("gform_paypal_fulfillment", array("GFUser", "add_paypal_user"), 10, 8); + if(self::is_user_registration_page()){ //enqueueing sack for AJAX requests @@ -169,10 +171,13 @@ public static function update_feed_active(){ //Integration with ManageWP public static function premium_update_push( $premium_update ){ - if( !function_exists( 'get_plugin_data' ) ) + if( !function_exists( 'get_plugin_data' ) ) { include_once( ABSPATH.'wp-admin/includes/plugin.php'); + } + + self::include_upgrade_library(); - $update = GFCommon::get_version_info(); + $update = RGUserUpgrade::get_version_info(self::$slug, self::get_key(), self::$version); if( $update["is_valid_key"] == true && version_compare(self::$version, $update["version"], '<') ){ $plugin_data = get_plugin_data( __FILE__ ); $plugin_data['type'] = 'plugin'; @@ -187,10 +192,13 @@ public static function premium_update_push( $premium_update ){ //Integration with ManageWP public static function premium_update( $premium_update ){ - if( !function_exists( 'get_plugin_data' ) ) + if( !function_exists( 'get_plugin_data' ) ) { include_once( ABSPATH.'wp-admin/includes/plugin.php'); + } + + self::include_upgrade_library(); - $update = GFCommon::get_version_info(); + $update = RGUserUpgrade::get_version_info(self::$slug, self::get_key(), self::$version); if( $update["is_valid_key"] == true && version_compare(self::$version, $update["version"], '<') ){ $plugin_data = get_plugin_data( __FILE__ ); $plugin_data['slug'] = self::$path; @@ -218,8 +226,8 @@ public static function plugin_row(){ else{ $version_info = RGUserUpgrade::get_version_info(self::$slug, self::get_key(), self::$version); - if(!$version_info["is_valid_key"]){ - $new_version = version_compare(self::$version, $version_info["version"], '<') ? __('There is a new version of Gravity Forms User Registration Add-On available.', 'gravityformsuserregistration') .' '. sprintf(__('View version %s Details', 'gravityformsuserregistration'), $version_info["version"]) . '. ' : ''; + if ( ! rgar($version_info, "is_valid_key" ) ) { + $new_version = version_compare(self::$version, rgar($version_info, "version"), '<') ? __('There is a new version of Gravity Forms User Registration Add-On available.', 'gravityformsuserregistration') .' '. sprintf(__('View version %s Details', 'gravityformsuserregistration'), rgar($version_info, "version") ) . '. ' : ''; $message = $new_version . sprintf(__('%sRegister%s your copy of Gravity Forms to receive access to automatic upgrades and support. Need a license key? %sPurchase one now%s.', 'gravityformsuserregistration'), '', '', '', '') . ''; RGUserUpgrade::display_plugin_message($message); } @@ -269,21 +277,23 @@ public static function create_menu($menus){ // Creates or updates database tables. Will only run when version changes private static function setup(){ - if(get_option("gf_user_registration_version") != self::$version) { - //loading data lib - require_once(self::get_base_path() . "/data.php"); + if( get_option( 'gf_user_registration_version' ) == self::$version ) + return; - GFUserData::update_table(); + // loading data lib + require_once( self::get_base_path() . '/data.php' ); - // create signups table for non-multisite installs - if(!is_multisite()) { - require_once(self::get_base_path() . '/includes/signups.php'); - GFUserSignups::create_signups_table(); - } + GFUserData::update_table(); - update_option("gf_user_registration_version", self::$version); + // create signups table for non-multisite installs + if( ! is_multisite() ) { + require_once( self::get_base_path() . '/includes/signups.php' ); + GFUserSignups::create_signups_table(); } + + update_option( 'gf_user_registration_version', self::$version ); + } // Adds feed tooltips to the list of tooltips @@ -559,11 +569,13 @@ public static function settings_page(){

-
- '; - echo apply_filters("gform_user_registration_uninstall_button", $uninstall_button); - ?> +
+

Warning

+ +
+
+ + ');">
@@ -847,13 +859,10 @@ private static function edit_page(){
@@ -1065,7 +1074,7 @@ function SelectForm(formId, configId){ function EndSelectForm(form_meta, form_fields, field_options, password_options, email_options, options_meta, bp_gform_options){ - var is_update_feed = jQuery('select#feed_type').val() == 'update'; + var isUpdateFeed = jQuery('select#feed_type').val() == 'update'; if(email_options == '' && jQuery('select#feed_type').val() == 'create') { displayMessage('Email fields. Please add an Email field and try again.', 'gravityformsuserregistration'); ?>', '#feed_settings'); @@ -1088,7 +1097,7 @@ function EndSelectForm(form_meta, form_fields, field_options, password_options, // create feed gets auto pass option, do not add to update feed jQuery.each(jQuery("select.password-field"), function(){ - var autoPass = is_update_feed ? '' : ''; + var autoPass = isUpdateFeed ? '' : ''; jQuery(this).html(password_options + autoPass); }); @@ -1096,16 +1105,18 @@ function EndSelectForm(form_meta, form_fields, field_options, password_options, jQuery(this).html(email_options); }); + var preserveRoleElements = jQuery( '#gf_user_registration_role, #gf_user_registration_multisite_root_role' ); + // update feed gets "Preserve current role" option for Role select, remove for create feed - if(is_update_feed) { + if( isUpdateFeed ) { // make sure an "preserve" option does not already exist - if(jQuery('option.perserve_role').length <= 0) { - var preserveRoleOption = jQuery(''); - preserveRoleOption.prependTo('select#gf_user_registration_role').prop('selected', true); + if( jQuery( 'option.perserve_role' ).length <= 0 ) { + var preserveRoleOption = jQuery( '' ); + preserveRoleOption.appendTo( preserveRoleElements ).prop( 'selected', true ); } jQuery('#gf_user_registration_send_email').hide(); } else { - jQuery('option.preserve_role').remove(); + jQuery( 'option.preserve_role' ).remove(); jQuery('#gf_user_registration_send_email').show(); } @@ -1768,7 +1779,20 @@ public static function get_buddypress_fields() { public static function save_buddypress_meta($config) { $json = stripslashes(RGForms::post("gf_buddypress_config")); - $config["meta"]["buddypress_meta"] = GFCommon::json_decode($json); + $data = GFCommon::json_decode($json); + $clean_data = array(); + + foreach( $data as $item ) { + + // possible user may want to "overwrite" meta with blank value so only check for name to ensure valid meta + if( empty( $item['meta_name'] ) ) + continue; + + $clean_data[] = $item; + + } + + $config["meta"]["buddypress_meta"] = $clean_data; return $config; } @@ -1776,7 +1800,11 @@ public static function save_buddypress_meta($config) { public static function prepare_buddypress_data($user_id, $config, $entry) { // required for user to display in the directory - bp_update_user_meta($user_id, 'last_activity', true); + if( function_exists( 'bp_update_user_last_activity' ) ) { + bp_update_user_last_activity( $user_id ); + } else { + bp_update_user_meta( $user_id, 'last_activity', true ); + } $buddypress_meta = rgars($config, 'meta/buddypress_meta'); @@ -1789,6 +1817,9 @@ public static function prepare_buddypress_data($user_id, $config, $entry) { $i = 0; foreach($buddypress_meta as $meta_item) { + if( empty( $meta_item['meta_name'] ) || empty( $meta_item['meta_value'] ) ) + continue; + $buddypress_row[$i]['field_id'] = $meta_item['meta_name']; $buddypress_row[$i]['user_id'] = $user_id; @@ -1822,6 +1853,8 @@ public static function prepare_buddypress_data($user_id, $config, $entry) { $buddypress_row[$i]['value'] = $meta_value; $buddypress_row[$i]['last_update'] = date( 'Y-m-d H:i:s' ); + $buddypress_row[$i]['field'] = $bp_field; + $i++; } @@ -1849,7 +1882,8 @@ public static function add_multisite_section($config, $form, $is_validation_erro get_current_site(); $form_fields = self::get_form_fields($form); - $multisite_options = rgar($config['meta'], 'multisite_options'); + $multisite_options = rgar( $config['meta'], 'multisite_options' ); + $root_role = rgar( $multisite_options, 'root_role' ); if(!self::is_root_site()) return; @@ -1889,7 +1923,7 @@ public static function add_multisite_section($config, $form, $is_validation_erro
@@ -1900,7 +1934,7 @@ public static function add_multisite_section($config, $form, $is_validation_erro @@ -1924,11 +1958,11 @@ function toggleNetworkOptions(elem) { jQuery('#gf_user_registration_role') .removeAttr('disabled') .parent('div').removeClass('disabled') - .find('option.empty-option').remove() - + .find('option.empty-option').remove(); } } + 1 ), $current_site->id); + $meta = apply_filters( 'gform_user_registration_new_site_meta', array( 'public' => 1 ), $form, $lead, $config, $user_id, $is_update_feed ); + $blog_id = wpmu_create_blog($site_data['domain'], $site_data['path'], $site_data['title'], $user_id, $meta, $current_site->id); if(is_wp_error($blog_id)) - return; + return false; // add entry ID to site meta for new site GFUserData::update_site_meta($blog_id, 'entry_id', $lead['id']); @@ -2049,14 +2085,18 @@ public static function create_new_multisite($user_id, $config, $lead, $password) $root_role = rgar($ms_options, 'root_role'); // if no root role, remove user from current site - if(!$root_role) { + if( ! $root_role ) { remove_user_from_blog($user_id); } + // preserve role, aka do nothing + else if( $root_role == 'gfur_preserve_role' ) { + } // otherwise, update their role on current site else { - $user = new WP_User($user_id); - $user->set_role($root_role); + $user = new WP_User( $user_id ); + $user->set_role( $root_role ); } + self::log_debug("Calling wpmu_welcome_notification to send multisite welcome - blog_id: {$blog_id} user_id: {$user_id}" ); wpmu_welcome_notification($blog_id, $user_id, $password, $site_data['title'], array('public' => 1)); self::log_debug("Done with wpmu_welcome_notification"); @@ -2091,19 +2131,25 @@ private static function get_paypal_config($form_id, $entry){ // Hook into Gravity Forms public static function gf_create_user($entry, $form, $fulfilled = false) { - self::log_debug("in gf_create_user"); + self::log_debug( "form #{$form['id']} - starting gf_create_user()." ); global $wpdb; // if the entry is marked as spam - if(rgar($entry, 'status') == 'spam') - return; + if(rgar($entry, 'status') == 'spam') { + self::log_debug( 'gf_create_user(): aborting. Entry is marked as spam.' ); + + return; + } $config = self::get_active_config($form, $entry); $is_update_feed = rgars($config, 'meta/feed_type') == 'update'; // if there is no registration feed or the feed is not active, abandon ship - if(!$config || !$config['is_active']) - return; + if(!$config || !$config['is_active']) { + self::log_debug( 'gf_create_user(): aborting. No feed or feed is inactive.' ); + + return; + } // if PayPal Add-on was used for this entry, integrate $paypal_config = self::get_paypal_config($form["id"], $entry); @@ -2117,19 +2163,28 @@ public static function gf_create_user($entry, $form, $fulfilled = false) { // - the order total does NOT equal zero (no delay since there will never be a payment) // - the payment has not already been fulfilled $delay_paypal_registration = $paypal_config['meta']['delay_registration']; - if($paypal_config && $delay_paypal_registration && $order_total != 0 && !$fulfilled) - return; + if($paypal_config && $delay_paypal_registration && $order_total != 0 && !$fulfilled) { + self::log_debug( 'gf_create_user(): aborting. Registration delayed by PayPal feed configuration.' ); + + return; + } } // provide filter to allow add-ons to disable registration if needed $disable_registration = apply_filters('gform_disable_registration', false, $form, $entry, $fulfilled); - if($disable_registration) - return; + if($disable_registration) { + self::log_debug( 'gf_create_user(): aborting. gform_disable_registration hook was used.' ); + + return; + } $user_data = self::get_user_data($entry, $form, $config, $is_update_feed); - if(!$user_data) - return; + if(!$user_data) { + self::log_debug( 'gf_create_user(): aborting. user_login or user_email are empty.' ); + + return; + } $user_activation = rgars($config, 'meta/user_activation'); @@ -2140,7 +2195,16 @@ public static function gf_create_user($entry, $form, $fulfilled = false) { require_once(self::get_base_path() . '/includes/signups.php'); GFUserSignups::prep_signups_functionality(); - $meta = array('lead_id' => $entry['id'], 'user_login' => $user_data['user_login'], 'email' => $user_data['user_email']); + $meta = array( + 'lead_id' => $entry['id'], + 'user_login' => $user_data['user_login'], + 'email' => $user_data['user_email'], + 'password' => self::encrypt( $user_data['password'] ), + ); + + $meta = apply_filters( 'gform_user_registration_signup_meta', $meta, $form, $entry, $config ); + $meta = apply_filters( "gform_user_registration_signup_meta_{$form['id']}", $meta, $form, $entry, $config ); + $ms_options = rgars($config, 'meta/multisite_options'); // save current user details in wp_signups for future activation @@ -2177,13 +2241,16 @@ public static function gf_create_user($entry, $form, $fulfilled = false) { } - public static function create_user($lead, $form, $config = false) { + public static function create_user( $lead, $form, $config = false, $password='' ) { self::log_debug("in create_user with form id " . $form["id"] . " and lead: " . print_r($lead, true)); if(!$config) $config = self::get_active_config($form, $lead); $meta = rgar($config, 'meta'); $user_data = self::get_user_data($lead, $form, $config); + if( !empty( $password ) ){ + $user_data['password'] = $password; + } $user_id = self::user_login_exists($user_data['user_login']); // @review, may not needs this here since we will likely handle updating user differently // create the user and password, then add user meta @@ -2194,7 +2261,7 @@ public static function create_user($lead, $form, $config = false) { $user_id = wp_create_user($user_data['user_login'], $user_data['password'], $user_data['user_email']); if(is_wp_error($user_id)) - return; + return false; update_user_option($user_id, 'default_password_nag', true, false); self::add_user_meta($user_id, $config, $form, $lead, array()); @@ -2204,7 +2271,7 @@ public static function create_user($lead, $form, $config = false) { self::log_debug("calling wp_create_user for login " . $user_data['user_login'] . " with email " . $user_data['user_email']); $user_id = wp_create_user($user_data['user_login'], $user_data['password'], $user_data['user_email']); if(is_wp_error($user_id)) - return; + return false; if(rgar($meta, 'password')) GFUserData::remove_password($form['id'], $lead['id'], rgar($meta, 'password')); @@ -2215,7 +2282,7 @@ public static function create_user($lead, $form, $config = false) { else { // if user with this username already exists, abort user registration - return; + return false; } @@ -2293,10 +2360,12 @@ public static function update_user($lead, $form, $config = false) { unset($user['user_pass']); } - $user_id = wp_update_user($user); + $user_id = wp_update_user( $user ); + $role = rgar( $meta, 'role' ); - if( rgar($meta, 'role') ) { - $user_obj->set_role(rgar($meta, 'role')); + // if a role is provied and it is not the 'preserve' option, update the role + if( rgar( $meta, 'role' ) && $role != 'gfur_preserve_role' ) { + $user_obj->set_role( rgar( $meta, 'role' ) ); } do_action('gform_user_updated', $user_id, $config, $lead, $user_data['password']); @@ -2379,6 +2448,8 @@ public static function gf_process_user($lead_id, $status, $prev_status) { private static function add_user_meta($user_id, $config, $form, $entry, $name_fields) { + self::log_debug('adding user meta'); + $standard_meta = array( 'firstname' => 'first_name', 'lastname' => 'last_name' @@ -2396,24 +2467,32 @@ private static function add_user_meta($user_id, $config, $form, $entry, $name_fi // add custom user meta $custom_meta = rgars($config, 'meta/user_meta'); + + if(is_array($custom_meta) && !empty($custom_meta)) { $value = ''; foreach($custom_meta as $custom_meta_item) { + self::log_debug("adding meta item: {$custom_meta_item['meta_name']}"); // skip empty meta items - if(!$custom_meta_item['meta_name'] || !$custom_meta_item['meta_value']) + if(!$custom_meta_item['meta_name'] || !$custom_meta_item['meta_value']){ + self::log_debug("Meta item is empty. Skipping it"); continue; + } $field = RGFormsModel::get_field($form, $custom_meta_item['meta_value']); $value = self::get_prepared_value($field, $custom_meta_item['meta_value'], $entry); + self::log_debug("Meta item mapped to field: {$field["id"]} - value: {$value}"); if($custom_meta_item['meta_name'] == 'user_url' && $value) { self::update_user_property($user_id, 'user_url', $value); } else if(rgblank($value)) { + self::log_debug("Deleting meta item since it has a blank value."); delete_user_meta($user_id, $custom_meta_item['meta_name']); } else{ + self::log_debug("Updating/Adding meta item."); update_user_meta($user_id, $custom_meta_item['meta_name'], $value); } } @@ -2659,7 +2738,7 @@ private static function get_prepared_value($field, $input_id, $entry, $is_userna switch(RGFormsModel::get_input_type($field)){ case "name": - if(strpos($input_id, '.') === false){ + if( strpos( $input_id, '.' ) === false && $field['nameFormat'] != 'simple' ) { $prefix = trim(rgar($entry, "{$input_id}.2")); $first = trim(rgar($entry, "{$input_id}.3")); $last = trim(rgar($entry, "{$input_id}.6")); @@ -2913,12 +2992,11 @@ public static function add_paypal_user($entry, $config, $transaction_id, $amount public static function downgrade_paypal_user($entry, $config, $transaction_id) { $paypal_config = self::get_paypal_config($entry['form_id'], $entry); - - if(!$paypal_config || !$paypal_config['meta']['update_user_action']) + if(!$paypal_config || !rgars($paypal_config, 'meta/update_user_action') ) return; $user = GFUserData::get_user_by_entry_id($entry['id']); - $user->set_role($paypal_config['meta']['update_user_action']); + $user->set_role( rgars($paypal_config, 'meta/update_user_action') ); } @@ -3278,8 +3356,7 @@ public static function custom_registration_page() { public static function get_user_id_by_meta($key, $value) { global $wpdb; - $table_name = $wpdb->prefix . "usermeta"; - $user = $wpdb->get_var($wpdb->prepare("select user_id from $table_name where meta_key = %s && meta_value = %s", $key, $value)); + $user = $wpdb->get_var($wpdb->prepare("select user_id from {$wpdb->usermeta} where meta_key = %s && meta_value = %s", $key, $value)); return !empty($user) ? $user : false; } @@ -3288,16 +3365,23 @@ private static function not_empty($value) { return $value; } - public static function display_role_dropdown_options($selected_role, $no_role_option = false) { + public static function display_role_dropdown_options( $selected_role, $no_role_option = false, $preserve_role_option = false ) { self::dropdown_roles( $selected_role ); - if(!is_multisite() || !$no_role_option) - return; - - $selected = !$selected_role ? 'selected="selected"' : ''; + if( $preserve_role_option ) { + printf( + '', + selected( $selected_role, 'gfur_preserve_role', false ), __( '— Preserve current role —' ) + ); + } - echo ''; + if( $no_role_option ) { + printf( + '', + selected( $selected_role, '', false ), __( '— No role for this site —' ) + ); + } } @@ -3433,7 +3517,8 @@ public static function prepopulate_form($form, $config) { foreach($buddypress_meta as $meta_item) { if(rgar($meta_item, 'meta_value')) { $field_id = rgar($meta_item, 'meta_value'); - $mapped_fields[(string)$field_id] = xprofile_get_field_data(rgar($meta_item, 'meta_name'), $user->ID); + $value = xprofile_get_field_data( rgar( $meta_item, 'meta_name' ), $user->ID ); + $mapped_fields[(string)$field_id] = is_array( $value ) ? array_map( 'html_entity_decode', $value ) : html_entity_decode( $value ); } } } @@ -3479,12 +3564,14 @@ public static function prepopulate_form($form, $config) { if(is_array($value)) { $cb_values = $value; } else { - foreach($field['inputs'] as &$input) { + $inputs = $field['inputs']; + foreach($inputs as &$input) { $cb_values[] = rgar($mapped_fields, (string)$input['id']); } + $field['inputs'] = $inputs; } - $value = implode(',', $cb_values); + $value = implode(',', $cb_values ); break; @@ -3512,13 +3599,13 @@ public static function prepopulate_form($form, $config) { // handle complex fields if(is_array(rgar($field, 'inputs'))) { - - foreach($field['inputs'] as &$input) { + $inputs = $field['inputs']; + foreach($inputs as &$input) { $filter_name = self::prepopulate_input( $input['id'], rgar($mapped_fields, (string)$input['id'])); $field['allowsPrepopulate'] = true; $input['name'] = $filter_name; } - + $field['inputs'] = $inputs; } else { $value = is_array(rgar($mapped_fields, $field['id'])) ? implode(',', rgar($mapped_fields, $field['id'])) : rgar($mapped_fields, $field['id']); @@ -3567,19 +3654,31 @@ public static function handle_existing_images_submission( $form ) { if( !$config ) return; - $user_meta = rgars( $config, 'meta/user_meta' ); - $upload_files = json_decode( rgpost('gform_uploaded_files'), ARRAY_A ); + $meta = rgars( $config, 'meta/user_meta' ); + + if( function_exists( 'xprofile_get_field_data' ) ) { + $bp_meta = rgars( $config, 'meta/buddypress_meta' ); + if( is_array( $bp_meta ) ) { + $bp_meta = array_map( create_function( '$a', '$a["is_bp"] = true; return $a;' ), $bp_meta ); + $meta = array_merge( $meta, $bp_meta ); + } + } - foreach( $user_meta as $meta_item ) { + foreach( $meta as $meta_item ) { $field = RGFormsModel::get_field( $form, $meta_item['meta_value'] ); $input_name = "input_{$field['id']}"; - if( RGFormsModel::get_input_type( $field ) != 'fileupload' ) + if( RGFormsModel::get_input_type( $field ) != 'fileupload' ) { continue; + } if( self::is_prepopulated_file_upload( $form['id'], $input_name ) ) { - $_gf_uploaded_files[$input_name] = get_user_meta( get_current_user_id(), $meta_item['meta_name'], true ); + if( rgar( $meta_item, 'is_bp' ) ) { + $_gf_uploaded_files[$input_name] = xprofile_get_field_data( $meta_item['meta_name'], get_current_user_id() ); + } else { + $_gf_uploaded_files[$input_name] = get_user_meta( get_current_user_id(), $meta_item['meta_name'], true ); + } } } @@ -3783,7 +3882,7 @@ public static function get_user_meta_keys($exclude = array()) { global $wpdb; $keys = array(); - $raw_keys = $wpdb->get_results("select distinct meta_key from {$wpdb->prefix}usermeta"); + $raw_keys = $wpdb->get_results( "select distinct meta_key from {$wpdb->usermeta}" ); foreach($raw_keys as $key) { if(!in_array($key->meta_key, $exclude)) @@ -3833,7 +3932,7 @@ public static function set_logging_supported($plugins) return $plugins; } - private static function log_error($message){ + public static function log_error($message){ if(class_exists("GFLogging")) { GFLogging::include_logger(); @@ -3841,7 +3940,7 @@ private static function log_error($message){ } } - private static function log_debug($message){ + public static function log_debug($message){ if(class_exists("GFLogging")) { GFLogging::include_logger(); @@ -3849,6 +3948,48 @@ private static function log_debug($message){ } } + public static function is_update_feed( $feed ) { + return rgars( $feed, 'meta/feed_type' ) == 'update'; + } + + + + //TODO: remove this when GFCommon has an updated version of encrypt() and decrypt() supporting encryption via mysql + public static function encrypt( $text ) { + $use_mcrypt = apply_filters('gform_use_mcrypt', function_exists( 'mcrypt_encrypt' ) ); + + if ( $use_mcrypt ){ + $iv_size = mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ); + $key = substr( md5( wp_salt( 'nonce' ) ), 0, $iv_size ); + + $encrypted_value = trim( base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, mcrypt_create_iv( $iv_size, MCRYPT_RAND ) ) ) ); + } + else{ + global $wpdb; + $encrypted_value = base64_encode( $wpdb->get_var( $wpdb->prepare('SELECT AES_ENCRYPT(%s, %s) AS data', $text, wp_salt( 'nonce' ) ) ) ); + } + + return $encrypted_value; + } + + //TODO: remove this when GFCommon has an updated version of encrypt() and decrypt() supporting encryption via mysql + public static function decrypt( $text ) { + + $use_mcrypt = apply_filters('gform_use_mcrypt', function_exists( 'mcrypt_decrypt' ) ); + + if ( $use_mcrypt ){ + $iv_size = mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ); + $key = substr( md5( wp_salt( 'nonce' ) ), 0, $iv_size ); + + $decrypted_value = trim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $key, base64_decode( $text ), MCRYPT_MODE_ECB, mcrypt_create_iv( $iv_size, MCRYPT_RAND ) ) ); + } + else{ + global $wpdb; + $decrypted_value = $wpdb->get_var( $wpdb->prepare('SELECT AES_DECRYPT(%s, %s) AS data', base64_decode( $text ), wp_salt( 'nonce' ) ) ); + } + + return $decrypted_value; + } }