/**
 * Record user signup information for future activation.
 *
 * This function is used when user registration is open but
 * new site registration is not.
 *
 * @since MU
 *
 * @param string $user       The user's requested login name.
 * @param string $user_email The user's email address.
 * @param array  $meta       By default, this is an empty array.
 */
function wpmu_signup_user($user, $user_email, $meta = array())
{
    global $wpdb;
    // Format data
    $user = preg_replace('/\\s+/', '', sanitize_user($user, true));
    $user_email = sanitize_email($user_email);
    $key = substr(md5(time() . rand() . $user_email), 0, 16);
    $meta = serialize($meta);
    $wpdb->insert($wpdb->signups, array('domain' => '', 'path' => '', 'title' => '', 'user_login' => $user, 'user_email' => $user_email, 'registered' => current_time('mysql', true), 'activation_key' => $key, 'meta' => $meta));
    wpmu_signup_user_notification($user, $user_email, $key, $meta);
    // Allow custom functionality upon a user signing up successfully
    do_action('MS_Custom_Signup\\wpmu_signup_user', $user, $user_email, $meta, $_REQUEST);
}
Exemplo n.º 2
0
/**
 * Record user signup information for future activation.
 *
 * This function is used when user registration is open but
 * new site registration is not.
 *
 * @since MU
 * @uses wpmu_signup_user_notification()
 *
 * @param string $user The user's requested login name.
 * @param string $user_email The user's email address.
 * @param array $meta By default, this is an empty array.
 */
function wpmu_signup_user($user, $user_email, $meta = '')
{
    global $wpdb;
    // Format data
    $user = preg_replace('/\\s+/', '', sanitize_user($user, true));
    $user_email = sanitize_email($user_email);
    $key = substr(md5(time() . rand() . $user_email), 0, 16);
    $meta = serialize($meta);
    $wpdb->insert($wpdb->signups, array('domain' => '', 'path' => '', 'title' => '', 'user_login' => $user, 'user_email' => $user_email, 'registered' => current_time('mysql', true), 'activation_key' => $key, 'meta' => $meta));
    wpmu_signup_user_notification($user, $user_email, $key, $meta);
}
 /**
  * Resend an activation email.
  *
  * @since 2.0.0
  *
  * @param array $signup_ids Single ID or list of IDs to resend.
  * @return array
  */
 public static function resend($signup_ids = array())
 {
     if (empty($signup_ids) || !is_array($signup_ids)) {
         return false;
     }
     $to_resend = self::get(array('include' => $signup_ids));
     if (!($signups = $to_resend['signups'])) {
         return false;
     }
     $result = array();
     /**
      * Fires before activation emails are resent.
      *
      * @since 2.0.0
      *
      * @param array $signup_ids Array of IDs to resend activation emails to.
      */
     do_action('bp_core_signup_before_resend', $signup_ids);
     foreach ($signups as $signup) {
         $meta = $signup->meta;
         $meta['sent_date'] = current_time('mysql', true);
         $meta['count_sent'] = $signup->count_sent + 1;
         // Send activation email.
         if (is_multisite()) {
             wpmu_signup_user_notification($signup->user_login, $signup->user_email, $signup->activation_key, serialize($meta));
         } else {
             // Check user status before sending email.
             $user_id = email_exists($signup->user_email);
             if (!empty($user_id) && 2 != self::check_user_status($user_id)) {
                 // Status is not 2, so user's account has been activated.
                 $result['errors'][$signup->signup_id] = array($signup->user_login, esc_html__('the sign-up has already been activated.', 'buddypress'));
                 // Repair signups table.
                 self::validate($signup->activation_key);
                 continue;
                 // Send the validation email.
             } else {
                 bp_core_signup_send_validation_email(false, $signup->user_email, $signup->activation_key, $signup->user_login);
             }
         }
         // Update metas.
         $result['resent'][] = self::update(array('signup_id' => $signup->signup_id, 'meta' => $meta));
     }
     /**
      * Fires after activation emails are resent.
      *
      * @since 2.0.0
      *
      * @param array $signup_ids Array of IDs to resend activation emails to.
      * @param array $result     Updated metadata related to activation emails.
      */
     do_action('bp_core_signup_after_resend', $signup_ids, $result);
     /**
      * Filters the result of the metadata for signup activation email resends.
      *
      * @since 2.0.0
      *
      * @param array $result Updated metadata related to activation emails.
      */
     return apply_filters('bp_core_signup_resend', $result);
 }
Exemplo n.º 4
0
 /**
  * Resends an activation email
  *
  * This sends exactly the same email the registrant originally got, using data pulled from
  * their registration. In the future I may add a UI for customized emails.
  *
  * @package Unconfirmed
  * @since 1.0
  *
  * @uses wpmu_signup_blog_notification() to notify users who signed up with a blog
  * @uses wpmu_signup_user_notification() to notify users who signed up without a blog
  */
 function resend_email()
 {
     global $wpdb;
     // Hubba hubba
     if (isset($_REQUEST['unconfirmed_bulk'])) {
         check_admin_referer('unconfirmed_bulk_action');
     } else {
         check_admin_referer('unconfirmed_resend_email');
     }
     // Get the user's activation key out of the URL params
     if (!isset($_REQUEST['unconfirmed_key'])) {
         $this->record_status('error_nokey');
         return;
     }
     $resent_counts = get_site_option('unconfirmed_resent_counts');
     $keys = $_REQUEST['unconfirmed_key'];
     foreach ((array) $keys as $key) {
         if ($this->is_multisite) {
             $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->signups} WHERE activation_key = %s", $key));
         } else {
             $user = $this->get_userdata_from_key($key);
         }
         if (!$user) {
             $this->record_status('error_nouser', $key);
             continue;
         }
         if ($this->is_multisite) {
             // We use a different email function depending on whether they registered with blog
             if (!empty($user->domain)) {
                 wpmu_signup_blog_notification($user->domain, $user->path, $user->title, $user->user_login, $user->user_email, $user->activation_key, maybe_unserialize($user->meta));
             } else {
                 wpmu_signup_user_notification($user->user_login, $user->user_email, $user->activation_key, maybe_unserialize($user->meta));
             }
         } else {
             // If you're running BP on a non-multisite instance of WP, use the
             // BP function to send the email
             if (function_exists('bp_core_signup_send_validation_email')) {
                 bp_core_signup_send_validation_email($user->ID, $user->user_email, $key);
             }
         }
         if (isset($resent_counts[$key])) {
             $resent_counts[$key] = $resent_counts[$key] + 1;
         } else {
             $resent_counts[$key] = 1;
         }
         // I can't do a true/false check on whether the email was sent because of
         // the crappy way that WPMU and BP work together to send these messages
         // See bp_core_activation_signup_user_notification()
         $this->record_status('updated_resent', $key);
     }
     update_site_option('unconfirmed_resent_counts', $resent_counts);
 }
Exemplo n.º 5
0
function wpmu_signup_user($user, $user_email, $meta = '')
{
    global $wpdb;
    $user = preg_replace("/\\s+/", '', sanitize_user($user, true));
    $user_email = sanitize_email($user_email);
    $key = substr(md5(time() . rand() . $user_email), 0, 16);
    $registered = current_time('mysql', true);
    $meta = serialize($meta);
    $wpdb->query("INSERT INTO {$wpdb->signups} ( domain, path, title, user_login, user_email, registered, activation_key, meta )\n\t\t\t\t\tVALUES ( '', '', '', '{$user}', '{$user_email}', '{$registered}', '{$key}', '{$meta}' )");
    wpmu_signup_user_notification($user, $user_email, $key, $meta);
}