Skip to content

Instantly share code, notes, and snippets.

@dmmoelle
Created January 2, 2018 20:47
Show Gist options
  • Save dmmoelle/3d5e3973b5e245c26ee99b0a3ff9bf34 to your computer and use it in GitHub Desktop.
Save dmmoelle/3d5e3973b5e245c26ee99b0a3ff9bf34 to your computer and use it in GitHub Desktop.
how do I pass the value form the sdate form input on line 20 into the sql query on line 85
<?php
/*
Plugin Name: Member payment report
Plugin URI: http://www.michiganjaycees.org
Description: this is a report showing the payments that have processed
Author: Dan Moellering
Version: .1
Author URI: http://mdmnow.com
*/
add_action('admin_menu', 'member_payment_report_action');
function member_payment_report_action () {
add_options_page('MemberPaymentReport', 'MemberPaymentReport', 'manage_options', __FILE__, 'memberPayment_admin');
}
function memberPayment_admin()
{
?>
<div class="wrap">
<h4>Membership Report</h4>
<form action="" method="POST">
<input type="date" name="sdate" value="pick-date" />
<input type="submit" name="search_orders" value="Search" class="button-primary" />
</form>
<br />
<table class="widefat">
<thead>
<tr>
<th>ID</th>
<th>Timestamp</th>
<th>User login</th>
<th>User email</th>
<th>Level</th>
<th>Total</th>
<th>Last name</th>
<th>First name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>DOB</th>
<th>Phone</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>Timestamp</th>
<th>User login</th>
<th>User email</th>
<th>Level</th>
<th>Total</th>
<th>Last name</th>
<th>First name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>DOB</th>
<th>Phone</th>
</tr>
</tfoot>
<tbody>
<?php
global $wpdb;
$memberquery = array();
if (isset($_POST['search_orders'])) {
$memberquery = $wpdb->get_results(
"
SELECT
o.user_id as user_id,
o.timestamp as timestampID,
(select user_login from wp_users where id = o.user_id limit 1) as user_login,
(select user_email from wp_users where id = o.user_id limit 1) as user_email,
(select name from wp_pmpro_membership_levels where id = o.membership_id limit 1) as level,
o.total as total,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_slastname' limit 1) as last_name,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_sfirstname' limit 1) as first_name,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_saddress1' limit 1) as address,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_scity' limit 1) as city,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_sstate' limit 1) as state,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_szipcode' limit 1) as zip,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'dob' limit 1) as dob,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'phone' limit 1) as phone
FROM wp_pmpro_membership_orders o
WHERE o.status = 'success' AND o.timestamp > 'sdate'
ORDER BY timestamp DESC;
"
);
update_option('membership_payment_memberquery', $memberquery ); //store the results in wp options table
}
else if (get_option('membership_payment_memberquery'))
{
$memberquery = get_option('membership_payment_memberquery');
}
foreach ($memberquery as $memberquery) {
?>
<tr>
<?php
echo '<td><a href="http://michiganjaycees.org/wp-admin/user-edit.php?user_id='.$memberquery->user_id.'" target="_blank">'.$memberquery->user_id.'</a></td>';
//echo "<td>".$memberquery->user_id."</td>";
echo "<td>".$memberquery->timestampID."</td>";
echo "<td>".$memberquery->user_login."</td>";
echo "<td>".$memberquery->user_email."</td>";
echo "<td>".$memberquery->level."</td>";
echo "<td>".$memberquery->total."</td>";
echo "<td>".$memberquery->last_name."</td>";
echo "<td>".$memberquery->first_name."</td>";
echo "<td>".$memberquery->address."</td>";
echo "<td>".$memberquery->city."</td>";
echo "<td>".$memberquery->state."</td>";
echo "<td>".$memberquery->zip."</td>";
echo "<td>".$memberquery->dob."</td>";
echo "<td>".$memberquery->phone."</td>";
?>
</tr>
<?php
}
?>
</tbody>
</div>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment