Created
February 2, 2015 09:04
-
-
Save JudeRosario/9ba68828ffc0bf894ac7 to your computer and use it in GitHub Desktop.
Membership Ping SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to get a list of users based on date joined / subscription type / level etc and refire pings | |
function refire_pings() | |
{ | |
global $wpdb; | |
// The query string ( see below for more examples ) | |
$query = "SELECT `ID` , `sub_id` , `level_id`, `user_email` , `user_login` , `display_name` | |
FROM `wp_m_membership_relationships` | |
INNER JOIN `wp_users` ON `wp_m_membership_relationships.user_id` = `wp_users.ID` | |
WHERE `startdate` | |
BETWEEN '2015-01-30 23:59:59' | |
AND '2015-02-01 23:59:59'" | |
$new_users = $wpdb->get_results($query); | |
// Loop through the each user and fire respective ping | |
foreach ($new_users as $user) { | |
// Get the level for each user (perform conditionals here if needed) | |
$level = Membership_Plugin::factory()->get_level( $user->level_id ); | |
// Get the Joining ping (can be any other ping type) | |
$joiningping_id = $level->get_meta( 'joining_ping' ); | |
// Fire the pings | |
if ( !empty( $joiningping_id ) ) { | |
$ping = new M_Ping( $joiningping_id ); | |
$ping->send_ping( false, $user->level_id, $user->ID); | |
} | |
} | |
return ; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Options include usinggateway, startdate, expirydate, updateddate, order_instance | |
SELECT `ID` , `sub_id` , `level_id`, `user_email` , `user_login` , `display_name` | |
# Primary key is rel_id | |
FROM `wp_m_membership_relationships` | |
# Primary key ID (WordPress .. duh !) | |
INNER JOIN `wp_users` ON `wp_m_membership_relationships.user_id` = `wp_users.ID` | |
# Filter based on startdate | |
WHERE `startdate` | |
# Date Range in YYYY-MM-DD HH-MM-SS format | |
BETWEEN '2015-01-30 23:59:59' | |
AND '2015-02-01 23:59:59' | |
# Variant of above | |
SELECT `ID` , `sub_id` , `level_id`, `user_email` , `user_login` | |
FROM `wp_m_membership_relationships` | |
INNER JOIN `wp_users` ON `wp_m_membership_relationships.user_id` = `wp_users.ID` | |
# Filter based on Subscription type or Access Level | |
WHERE `sub_id` =2 | |
OR `level_id` = 1 | |
# Based on email address | |
SELECT `ID` , `sub_id` , `level_id`, `user_email` , `user_login` | |
FROM `wp_m_membership_relationships` | |
INNER JOIN `wp_users` ON `wp_m_membership_relationships.user_id` = `wp_users.ID` | |
# Filter based on email address | |
WHERE `user_email` | |
LIKE %gmail% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment