Setup on front end sign up form.
*/
public function getNotificationsByType( $type )
{
- return $this->wpdb->get_results(
+ return $this->wpdb->get_var(
$this->wpdb->prepare(
"SELECT id
FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "notification_types
WHERE send_by_action
AND send_action = %d",
$this->config['send_action_numb'][$type]
- ),
- ARRAY_A
+ )
);
}
"SELECT id
FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "notification_queue
WHERE notification_type = %d
- AND account = %d",
+ AND account = %d
+ AND processed_time IS NULL",
$notification_type,
$account
)
GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'notification_queue',
array(
'notification_type' => $notification_type,
- 'account' => $account
+ 'account' => $account,
+ 'queued_time' => date('Y-m-d H:i:s')
),
array(
'%d',
- '%d'
+ '%d',
+ '%s'
)
);
}
* @access public
* @return array
*/
- public function getQueuedNotifications( $limit )
+ public function getQueuedNotifications( $limit = null )
{
$query =
"SELECT *
FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "notification_queue";
- //$query = " WHERE processed_time IS NULL";
+ $query .= " WHERE processed_time IS NULL";
if ( $numb = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
- $query .= " LIMIT $limit OFFSET 0";
+ $query .= " LIMIT $numb OFFSET 0";
}
return $this->wpdb->get_results(
$query,
{
$this->wpdb->update(
GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'notification_queue',
- array( 'processed_time' => date( 'Y-m-d' ) ),
+ array( 'processed_time' => date( 'Y-m-d H:i:s' ) ),
array( 'id' => $queue_id ),
array( '%s' ),
array( '%d' )
; Send Action
send_action[10] = "Create Invoice"
send_action[20] = "Received Payment"
+send_action[30] = "New Member"
send_action_numb['Create Invoice'] = 10;
send_action_numb['Received Payment'] = 20;
+send_action_numb['New Member'] = 30;
; Send Date When
send_date_when[10] = "Before"
// Get the queue and send notices.
$queued = $Notifications->getQueuedNotifications();
echo '<pre>$queued: ' . print_r( $queued, true ) . '</pre>';
+ // return false;
if ( isset( $queued ) && !empty( $queued ) ) {
foreach ( $queued as $queue ) {
$Notifications->sendEmailNotification( $queue['notification_type'], $queue['account'] );
// $Notifications->deleteQueue( $queue['id'] );
}
}
- wp_die();
}
}
}
$accounts = $billingSupport->getAccountsRenewing( $notice['send_date_number'], $before );
echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
+ // return false;
if ( isset( $accounts ) && is_array( $accounts ) && !empty( $accounts ) ) {
foreach ( $accounts as $account ) {
$Notifications->queueNotice( $notice['id'], $account['id'] );
}
}
- wp_die();
}
}
define('GLM_MEMBERS_BILLING_MEMBER_MENU', true);
require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataInvoices.php';
require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/billingSupport.php';
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/notifications.php';
class GlmMembersFront_billing_becomeMember // extends GlmDataBilling
{
case 'newMembership':
$payable_types = $BillingSupport->getAllPayableInvoiceTypes();
- $messages[] = '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+ // $messages[] = '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
// Need to see if the email address they're using is already setup as a contact.
// If it is then we need to give a message about it and not let them sign up again.
$email_to_check = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL );
- $messages[] = '<pre>$email_to_check: ' . print_r( $email_to_check, true ) . '</pre>';
+ // $messages[] = '<pre>$email_to_check: ' . print_r( $email_to_check, true ) . '</pre>';
$verify_email = filter_var( $_REQUEST['email_verify'], FILTER_VALIDATE_EMAIL );
- $messages[] = '<pre>$verify_email: ' . print_r( $verify_email, true ) . '</pre>';
+ // $messages[] = '<pre>$verify_email: ' . print_r( $verify_email, true ) . '</pre>';
if ( !$email_to_check ) {
$error = true;
$messages[] = $errors['email'] = "<span style='color: red;'>Not a valid Email!</span>";
'role' => $wpRole
)
);
+ // echo '<pre>$wpUserID: ' . print_r( $wpUserID, true ) . '</pre>';
if (is_int($wpUserID) && $wpUserID > 0) {
// Store the contact ID and active status into user meta data.
update_user_meta($wpUserID, 'glmMembersContactID', $newContactID);
update_user_meta($wpUserID, 'glmMembersContactActive', true);
// echo '<pre>$wpUserID: ' . print_r( $wpUserID, true ) . '</pre>';
+ } else if ( is_wp_error( $wpUserID ) ) {
+ $error = true;
+ $messages[''] = $errors['username'] = '<span style="color:red;">An error occurred! ' . $wpUserID->get_error_message() . '</span>';
} else {
$error = true;
$messages[] = '<span style="color:red;">An error occurred! wpUserID</span>';
} else {
$invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
$view = 'thankyou';
+ // Send admin user email notification of new member
+
+ // Check for any notices for new members and send them out for this new member.
+ $Notification = new GlmNotifications( $this->wpdb, $this->config );
+ $notification = $Notification->getNotificationsByType( 'New Member' );
+ if ( $notification ) {
+ $Notification->sendEmailNotification( $notification, $accountID );
+ }
}
}
break;
1
);
-// add_filter(
-// 'glm_associate_cron_request',
-// function( $cron_task ){
-// $new_cron = array(
-// array(
-// 'menu' => 'ajax',
-// 'action' => 'billingFlagExpiredUsers',
-// 'daysOfWeek' => range( 1, 7 ),
-// 'times' => range( 1, 24 ),
-// 'params' => array()
-// )
-// );
-// return array_merge( $cron_task, $new_cron );
-// }
-// );
+add_filter(
+ 'glm_associate_cron_request',
+ function( $cron_task ){
+ $new_cron = array(
+ array(
+ 'menu' => 'ajax',
+ 'action' => 'billingFlagExpiredUsers',
+ 'daysOfWeek' => range( 1, 7 ),
+ 'times' => range( 1, 24 ),
+ 'params' => array()
+ )
+ );
+ return array_merge( $cron_task, $new_cron );
+ }
+);
-// add_filter(
-// 'glm_associate_cron_request',
-// function( $cron_task ) {
-// $new_cron = array(
-// array(
-// 'menu' => 'ajax',
-// 'action' => 'billingSetupQueue',
-// 'daysOfWeek' => range( 1, 7 ),
-// 'times' => range( 1, 24 ),
-// 'params' => array()
-// )
-// );
-// return array_merge( $cron_task, $new_cron );
-// }
-// );
+add_filter(
+ 'glm_associate_cron_request',
+ function( $cron_task ) {
+ $new_cron = array(
+ array(
+ 'menu' => 'ajax',
+ 'action' => 'billingSetupQueue',
+ 'daysOfWeek' => range( 1, 7 ),
+ 'times' => range( 3 ),
+ 'params' => array()
+ )
+ );
+ return array_merge( $cron_task, $new_cron );
+ }
+);
-// add_filter(
-// 'glm_associate_cron_request',
-// function( $cron_task ) {
-// $new_cron = array(
-// array(
-// 'menu' => 'ajax',
-// 'action' => 'billingRunQueue',
-// 'daysOfWeek' => range( 1, 7 ),
-// 'times' => range( 1, 24 ),
-// 'params' => array()
-// )
-// );
-// return array_merge( $cron_task, $new_cron );
-// }
-// );
+add_filter(
+ 'glm_associate_cron_request',
+ function( $cron_task ) {
+ $new_cron = array(
+ array(
+ 'menu' => 'ajax',
+ 'action' => 'billingRunQueue',
+ 'daysOfWeek' => range( 1, 7 ),
+ 'times' => range( 4 ),
+ 'params' => array()
+ )
+ );
+ return array_merge( $cron_task, $new_cron );
+ }
+);
required />
</div>
</div>
+ {if $errors.username}<div>{$errors.username}</div>{/if}
<div>
The password must be at least 8 characters and include at least one number, one letter, and at least one special character. (# . - _ , $ % & !)
</div>