Skip to content

Commit

Permalink
Merge branch 'release/2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Nov 6, 2014
2 parents feb2939 + df723c8 commit a96b4e7
Show file tree
Hide file tree
Showing 7 changed files with 816 additions and 319 deletions.
40 changes: 40 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

}
Expand Down
2 changes: 1 addition & 1 deletion includes/pending_activations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
103 changes: 73 additions & 30 deletions includes/signups.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,66 @@
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 );
}

}

/**
* Add signups property to $wpdb object. Used by several MS functions.
*/
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() {
Expand All @@ -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' ) );

Expand All @@ -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() . '/' );
Expand All @@ -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());
Expand Down Expand Up @@ -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){
Expand Down
Loading

0 comments on commit a96b4e7

Please sign in to comment.