latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

About: Quentin Algood

Sorry, I've not written a description yet. I'll get to it soon!


My Favorite Topics

Viewing topic 1 (of 1 total)
Topic Count Last Reply
User/Member Export CSV is Garbled

By:  Nigel in: Community Forum

voices: 3
replies: 9

4 years, 10 months ago  Cristián Lávaque

Viewing topic 1 (of 1 total)

Topics I'm Subscribed To


Topics I've Started

Viewing 3 topics - 1 through 3 (of 3 total)
Topic Count Last Reply
EOT column not displaying data for users

By:  Quentin Algood in: Community Forum

voices: 5
replies: 10

4 years, 1 month ago  Bruce

Date based EOT instead of fixed duration

By:  Quentin Algood in: Community Forum

voices: 2
replies: 3

4 years, 3 months ago  Raam Dev

Will s2member import handle all user meta?

By:  Quentin Algood in: Community Forum

voices: 2
replies: 1

4 years, 3 months ago  Cristián Lávaque

Viewing 3 topics - 1 through 3 (of 3 total)

My Latest Replies (From Various Topics)

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Monday Nov 26th, 2012 at 11:20 am #32596

The incompatibility is with Ajax Event Calendar. When Ajax Event Calendar is disabled, the EOT column displays properly.

The plugin functionality that may cause this issue is:

Track the number of events created by each user in the Users menu

A quick fix is to disable the functionality by editing ajax-event-calendar.php like so:

// wordpress overrides
//add_filter('manage_users_columns', array($this, 'add_events_column'));
//add_filter('manage_users_custom_column', array($this, 'add_events_column_data'), 10, 3);

Of course, the edit doesn’t fix the cause of incompatibility. If anyone sees the reason for incompatibility in the Ajax Event Calendar plugin code, please chime in:

// CUSTOMIZE WORDPRESS
// adds column field label to WordPress users page
function add_events_column($columns) {
	$columns['calendar_events'] = __('Events', AEC_NAME);
	return $columns;
}

// adds column field value to WordPress users page
function add_events_column_data($empty='', $column_name, $user_id) {
	if ($column_name == 'calendar_events') {
		return $this->db_query_events_by_user($user_id);
	}
}
function db_query_events_by_user($user_id) {
	global $wpdb;
	$result = $wpdb->get_var($wpdb->prepare('SELECT count(id)
		 FROM ' . $wpdb->prefix . AEC_EVENT_TABLE . '
		 WHERE user_id = %d;', $user_id));
	return $this->return_result($result);
}
function return_result($result) {
	if ($result === false) {
		global $wpdb;
		$this->log($wpdb->print_error());
		return false;
	}
	return $result;
}
function log($message) {
	if (is_array($message) || is_object($message)) {
		error_log(print_r($message, true));
	} else {
		error_log($message);
	}
	return;
}
  • This reply was modified 4 years, 1 month ago by  Quentin Algood.
  • This reply was modified 4 years, 1 month ago by  Quentin Algood. Reason: code
  • This reply was modified 4 years, 1 month ago by  Quentin Algood. Reason: more code
  • This reply was modified 4 years, 1 month ago by  Quentin Algood.
Posted: Tuesday Nov 13th, 2012 at 12:11 pm #31456

I replaced the entirety of my s2-hacks.php file with just Bruce’s code, and the result is the same. I’m going to deactivate other plugins until this works to see if I have a plugin conflict.

Posted: Monday Nov 12th, 2012 at 8:16 pm #31394

Yes. This is /wp-content/mu-plugins/s2-hacks.php

<?php

/*
* Code to order columns adopted from http://wordpress.org/support/topic/make-extra-columns-in-userphp-sortable#post-2810255
*
* Hack tested s2Member v120703; WordPress version 3.4.2; PHP v5.4 on September 25, 2012
*/

add_filter('manage_users_columns', 's2hack_eot_column_add');
function s2hack_eot_column_add($col)
	{
		$col['s2member_auto_eot_time'] = 'EOT'; # Set title for column
		return $col;
	}

add_filter('manage_users_custom_column', 's2hack_eot_column_edit_val', 10, 3);
function s2hack_eot_column_edit_val($val, $col_name, $id)
	{
		$user = get_userdata($id); # Get the user's info
		
		if($col_name === 's2member_auto_eot_time' && ($eot = get_user_field('s2member_auto_eot_time', $user->ID))) # If column is for EOT, and user's EOT date is not empty
			return date("D M dS, Y".'<\b\r /><\s\m\a\l\l>'."@\p\\r\\e\c\i\s\\e\l\y g:i a".'</\s\m\a\l\l>', $eot); # return the date user's membership expires (using same standards as s2Member registration date layout)
		
		elseif($col_name === 's2member_auto_eot_time') # Otherwise, if the user does not have an EOT date
			return '--'; # Just return -- as s2Member does normally
		
		else return $val; # Otherwise, we don't need to edit this
	}

add_action('pre_user_query', 's2hack_eot_column_query'); # This could also be changed from pre_user_query to query, but easier to work with an object (pre_user_query) than a string(query)
function s2hack_eot_column_query($query)
	{
		global $wpdb; # Get WordPress database class / for prefix
		$vars = $query->query_vars; # Query variables reassigned for easier access
		
		if($vars['orderby'] === 's2member_auto_eot_time') # If querying the s2Member Automatic EOT times
			{
				// Could var_dump($query) here if need to know the values within the $query Object
				$query->query_from .= " LEFT JOIN ".$wpdb->prefix."usermeta m ON (".$wpdb->prefix."users.ID = m.user_id  AND m.meta_key = '".$wpdb->prefix."$vars[orderby]')"; # Append meta values for s2Member EOT times...
				$query->query_orderby = "ORDER BY m.meta_value ".$vars['order']; # ...and order by these times by EOT in ASC or DESC order, depending on the query
			}
	}

add_filter('manage_users_sortable_columns', 's2hack_eot_column_add_sort');
function s2hack_eot_column_add_sort($columns)
	{
		$columns['s2member_auto_eot_time'] = 's2member_auto_eot_time'; # Add eot column to sortable columns
		return $columns; # Then return all sortable columns
	}

// hack to deliver paypal button with date based expiration
// no longer used now that club expires all memberships on 7/1
add_action("ws_plugin__s2member_before_sc_paypal_button", "s2_hacks_eot_by_date");
function s2_hacks_eot_by_date($vars = array())
{
	if ($vars["attr"]["expire"] && $vars["attr"]["cutoff"])	
	{
		$expire = strtotime($vars["attr"]["expire"] . "+1 day"); // Include all of the last day
		$cutoff = strtotime($vars["attr"]["cutoff"] . "+1 day"); // Include all of the last day
		$now = time();
		if($now > $cutoff) {
			$expire = strtotime(date("Y-m-d", $expire) . "+1 year"); // Add one year if after cutoff
		}
		$timeleft = $expire-$now;
		$daysleft = round((($timeleft/24)/60)/60) + 1; // Add one day to include the last day
		$vars["attr"]["rp"] = $daysleft; // Set the number of days
		$vars["attr"]["rt"] = "D"; // Set the rate term to days
		$vars["attr"]["custom"] .= "|" . date("Y-m-d", $expire); // Append computed EOT to the custom field
		unset($vars["attr"]["expire"]);
		unset($vars["attr"]["cutoff"]);
	}
	return;
}




?>
Posted: Friday Nov 9th, 2012 at 12:13 pm #31143

The first image is from the Users panel in the Dashboard. The second image displays the EOT for the user with a transaction ID in the first image. Even when I modify Bruce’s hack in s2-hacks.php to change the output of the EOT column value when none exists, the column only contains instances of “–“.

Posted: Tuesday Oct 9th, 2012 at 5:46 pm #27933

Tracy, have you tried changing your active theme to a default WordPress theme? If after doing so your page titles return, I would point my finger at your theme’s header configuration.

Posted: Tuesday Oct 9th, 2012 at 5:37 pm #27932

Hi Raam, thanks for your reply. From your explanation, I was on the right track. These steps produce a date-based EOT without enabling PHP execution (in PayPal button shortcodes). If you see anything alarming or potentially dangerous with this setup, please say so.

First, I created the s2-hacks.php file as outlined here and wrote this custom function, attached to the ws_plugin__s2member_before_sc_paypal_button action.

<?php
add_action("ws_plugin__s2member_before_sc_paypal_button", "s2_hacks_eot_by_date");
function s2_hacks_eot_by_date($vars = array())
{
	if ($vars["attr"]["expire"] && $vars["attr"]["cutoff"])	
	{
		$expire = strtotime($vars["attr"]["expire"] . "+1 day"); // Include all of the last day
		$cutoff = strtotime($vars["attr"]["cutoff"] . "+1 day"); // Include all of the last day
		$now = time();
		if($now > $cutoff) {
			$expire = strtotime(date("Y-m-d", $expire) . "+1 year"); // Add one year if after cutoff
		}
		$timeleft = $expire-$now;
		$daysleft = round((($timeleft/24)/60)/60) + 1; // Add one day to include the last day
		$vars["attr"]["rp"] = $daysleft; // Set the number of days
		$vars["attr"]["rt"] = "D"; // Set the rate term to days
		$vars["attr"]["custom"] .= "|" . date("Y-m-d", $expire); // Append computed EOT to the custom field
		unset($vars["attr"]["expire"]);
		unset($vars["attr"]["cutoff"]);
	}
	return;
}
?>

Next, I wrote the PayPal button shortcode, adding values for expiration and a cut off date.

[s2Member-PayPal-Button level="1" ccaps="" desc="Individual Member / non-recurring" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="domain.com" ta="0" tp="0" tt="D" ra="20.00" rp="1" rt="Y" rr="BN" rrt="" rra="1" image="default" output="button" expire="6/30" cutoff="3/31" /]

With the expire and cutoff values added to the shortcode, the custom function modifies the PayPal button:

  • custom="domain.com" is appended with the expiration date "|YYYY-MM-DD"
  • rp="1" is changed to the number of days remaining to and including the expiration date
  • rt="Y" is changed to rt="D"

I use Simple/Shortcode Conditionals to hide this button from members above level 0.

Members above level 0 have active memberships with an EOT already configured for the desired month/day. With Fixed-Term Extensions set to Yes, I use this shortcode to allow renewals of one year:

[s2Member-PayPal-Button level="1" ccaps="" desc="Individual Member / non-recurring" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="domain.com" ta="0" tp="0" tt="D" ra="20.00" rp="1" rt="Y" rr="BN" rrt="" rra="1" image="default" output="button" /]

Again, if any of this looks as if it will break something important, please say so.

Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.