Amr events plugin (alpha) available
By · CommentsAn alpha version of the new amr events plugin for wordpress is available. The zip file will actually produce two plugins (one is an upgraded version of the “free” event listing plugin). These files will be cleaned up and rationalised in the next upgrade. I wanted to make a version available asap for testers.
Try before you buy
Download
Free copies
The following may also request free access to this and future upgrades:
- not-for-profits (tell me which domain it’s for – I reserve the right to refuse if it advocates anything I disagree with…. I’m pretty open minded but advocates of violence, hatred, bigotry, racists etc need not apply!
- anyone who has donated a reasonable amount (you know who you are… just email me with a reminder and I’ll send you a copy)
- and authors of most other plugins…..
Support and Bugs
For now, log
- any general support queries as a comment on this post:
- bugs or feature requests at bugs.anmari.com
What is detailed, specific feedback?
If you find a bug, please log it at bugs.anmari.com and describe
- under what conditions does it happen? – whatever information may be relevant to identify the cause
- how could I recreate it – what data was used or other plugins etc
- what messages if any?
Missing documentation or situations where it is not clear what to do are “bugs” too. Good software is not just technically working code! So if you get confused tell me what would have helped.
Missed Expectations – If it did not do what you expected and there is more you wanted it to do, please try to describe the features you were thinking of in as much detail as possible with examples and if possible screenshots. Images can be loaded at bugs.anmari.com and you can create feature requests there too and vote for any existing.
Positive feedback – If the plugin does what you expected it to do and what you wanted it to do, please say that and tell me what aspects were most valuable and why.
amr user templates v1.0 download
By · CommentsThe User Template plugin which helps you simplify member admin screens is now available for download. Access is for registered users who have purchased access to this post or who have been upgraded for free . Notforprofits, and selected others, please register using the free option and then email me your username and the domain you wish to use the plugin on. I’ll upgrade you as soon as I can!
Given a date, get the next or previous Monday, or Tuesday etc from the given date. This is useful when working with ical recurring dates. If the date given is already that day of week, it is returned as the result.
For example to get the following
Every 20th Monday of the year, forever:
DTSTART;TZID=US-Eastern:19970519T090000
RRULE:FREQ=YEARLY;BYDAY=20MO==> (1997 9:00 AM EDT)May 19
(1998 9:00 AM EDT)May 18
(1999 9:00 AM EDT)May 17
One could get the first Monday of the year, the it is fairly easy to get the 20th !
<?php
global $amr_day_of_week_no;
$amr_day_of_week_no = array (
'MO' => 1,
'TU' => 2,
'WE' => 3,
'TH' => 4,
'FR' => 5,
'SA' => 6,
'SU' => 0
);
function amr_goto_byday ($dateobj, $byday, $sign) {
global $amr_day_of_week_no;
$dayofweek = $dateobj->format('w'); /* 0=sunday, 6 = saturday */
if ($dayofweek == '-1') $dayofweek = get_oldweekdays($dateobj); /* php seems to break around 1760 */
$target = $amr_day_of_week_no[$byday]; /* mo=1 ,su=7 */
$adjustment = $target - $dayofweek;
if ($sign === '+') {
if ($adjustment < 0) $adjustment = $adjustment + 7;
}
else if ($adjustment > 0) $adjustment = $adjustment-7;
$d2 = new DateTime();
$d2 = clone ($dateobj);
date_modify ($d2,$adjustment.' days');
return ($d2);
}
/* --------Test data ------------------------- */
$d[] = new DateTime('2009-12-25');
$d[] = new DateTime('2009-12-28');
$d[] = new DateTime('2009-12-29');
$d[] = new DateTime('2009-12-30');
$d[] = new DateTime('2009-12-31');
$d[] = new DateTime('2010-01-01');
$d[] = new DateTime('2010-01-02');
$d[] = new DateTime('2010-01-03');
$d[] = new DateTime('2010-01-04');
$d[] = new DateTime('2010-01-05');
$d[] = new DateTime('2010-01-06');
$d[] = new DateTime('2010-01-07');
$d[] = new DateTime('2010-01-08');
$d[] = new DateTime('2010-01-09');
$d[] = new DateTime('2010-01-10');
$d[] = new DateTime('2010-01-11');
echo '<table>';
foreach (array ('TU','WE','TH','FR','SA','SU','MO') as $day) {
echo '<tr><td> Aiming for '.$day.'</td><td>If not this, then next</td><td>If not this, then prev</td></tr>';
foreach ($d as $i => $d2) {
$d3 = amr_goto_byday ($d2, $day, '+');
$d4 = amr_goto_byday ($d2, $day, '-');
$s = $d2->format('Y m d l');
echo '<tr><td> '.$s.'</td><td>'.$d3->format('l,Y m d').'</td><td>'.$d4->format('l,Y m d').'</td></tr>';
}
}
echo '</table>';
?>
Day of week for historical dates earlier than 1760
By · CommentsOne of the ics files that I encountered in testing my events list plugin came from Google and had a “Zero Year” date in it. There were probably reasons for this and I have to be thankful for the happening - In looking into it I foundthat the php date format function for day of week $dateobj->format(‘w’); “breaks” around the year 1760 and starts returning a “-1″. Since I do have people using my plugin for anniversaries with earlier start dates (It’s not all musical gigs and sporting events!), I felt I needed to cope with it.
I now use the following code, which appears to work when comparing the weekdays using http://www.searchforancestors.com/utility/dayofweek.html
$w = $dateobj->format('w');
if ($w == '-1') $w = get_oldweekdays($dateobj);
function get_oldweekdays ($d) {
$dummy = new DateTime();
$dummy = clone ($d);
date_modify($dummy,'+91500 weeks');
/* add weeks to get us back to a "working" date -
a guess from when the date started breaking, plus some extra to be safe */
$w = $dummy->format('w');
return($w);
}

Remove a column in wordpress for all your users
By · CommentsJust saw a new plugin pop up on the dashboard that “removes the author column” in the edit post window for single author blogs. (?!!)
Why ? What’s wrong with using the screen options ?
One of the motivations touted was that it “releases” screen real estate so you can add in other columns with other plugins. Well yes, but that’s what the screen options are for.
Each additional column’s value is called in a function. If that field is not to be displayed, then the function will not be called. This is the beauty of using the wordpress screen options – one can have more columns than look nice on the screen as a default and then tailor it with the screen options, choosing the fields that make sense for you.
But I want it for ALL my users
If you need to do this for all your users, then consider the amr-user-templates plugin rather – it works “with” wordpress rather than against it.
Calculate date from day of year in php
By · CommentsHere is a simple first of several notes on useful date functions. This function accepts a year (YYYY) and a Day in the year (1 to 366), and returns a DateTime Object.
/* Year if format YYYY, Day in year 1 to 366 */function dayofyear2date( $year, $DayInYear ) {
$d = new DateTime($year.'-01-01');
date_modify($d, '+'.($DayInYear-1).' days');
return ($d);
}
I’m tired of seeing Unix time stamp code examples that break with older dates. Since my ical calendar scripts can potentially hold recurring dates that are anniversaries and birthdays, my scripts need to cope with dates earlier than 1970, and with timezones and daylight saving, so I use the DateTime class exclusively now.
Test Script To Check Function
<?php
function dayofyear2date( $year, $DayInYear ) {
$d = new DateTime($year.'-01-01');
date_modify($d, '+'.($DayInYear-1).' days');
return ($d);
}
$d[] = new DateTime('1950-12-31');
$d[] = new DateTime('1970-01-01');
$d[] = new DateTime('2010-01-01');
$d[] = new DateTime('2010-12-27');
$d[] = new DateTime('2010-12-31');
foreach ($d as $i => $d2) {
$dayofyear = $d2->format('z')+1;
$date = dayofyear2date (
$d2->format('Y'),
$dayofyear ); /* note z returns days from 0 */
echo '<br /><b>'.$d2->format('Y m d')
.'</b> '.$dayofyear.' <br />'
.$date->format('Y m d');
}
?>
Ver 2.3.4 of users lists – additional formatting options
By · CommentsIf you are using the amr-users plugin to provide a public user list or directory and you want to have the pagination working, there is a small bug when permalinks are used. IE does not happen in admin.
Note:
- if you have a short list you can simply set the rows per page to avoid pagination kicking in.
- please consider user privacy when deciding what fields to include in the public list.
To correct this, edit file ameta-includes.php, from about Line 393, it should look like this:
(Note you can delete the commented out bits, just in for clarity of change).
//if (isset($_GET['listpage'])) $oldpage = $_GET['listpage'];//else $oldpage = '';$base = remove_query_arg ('listpage', $_SERVER['QUERY_STRING']);//$base = str_replace('&listpage='.$oldpage,'',$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);//$base = str_replace('?listpage='.$oldpage,'',$base); /* just in case */if (!empty($_SERVER['QUERY_STRING']) ) $format = '&listpage=%#%'; // ?page=%#% : %#% is replaced by the page numberelse $format = '?listpage=%#%';$paging_text = paginate_links( array( /* uses wordpress function */ 'total' => $totalpages, 'current' => $thispage, // 'base' => $base.'%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) 'base' => @add_query_arg('listpage','%#%'), 'format' => '', 'end_size' => 2, 'mid_size' => 1, 'add_args' => false ) );
A revised version will be up soon, but I’d like to see if I can roll a few minor features into before doing an update.
Thanks to NinaJ for reporting this
V2.3.3 bug fix needed if using S2member or similar
By · CommentsThis version has a bug fix that may affect reports that use data created by any plugins that store arrays in the usermeta. Very other non-serious tweaks were made. And a all-in-one background batch cache create option was added.
So now you can push all those buttons at once!
As always, it may take awhile to show up on your update list and on wordpress.
WordPress user editing problems
By · CommentsI am playing with “Your Members” again and deactivated it to get some clean screenshots of one of my plugins - I was bemused to discover that this error had not been fixed in wordpress (It is now milestoned for 3.1)
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string
The cause is that one deactivates a plugin that had stored some object data in the usermeta table (where it should, rather than creating new tables). However if it creates it’s own object (and why should it not?) then if the code is not around to read that object this message occurs and you cannot save your user data!
The problem in my view is a wordpress one.
There is a patch which is ‘old’, but for some reason not applied to wp 3.0. The quick fix is to apply the patch. So for 3.01, wp-includes/functions.php lines 1458 to 1469
Replace this:
function add_magic_quotes( $array ) { global $wpdb; foreach ( (array) $array as $k => $v ) { if ( is_array( $v ) ) { $array[$k] = add_magic_quotes( $v ); } else { $array[$k] = $wpdb->escape( $v ); } } return $array; }
With this:
function add_magic_quotes( $array ) { global $wpdb; if ( is_array($array) ) { foreach ( $array as $k => $v ) { $array[$k] = add_magic_quotes( $v ); } } elseif ( is_string($array) ) { $array = $wpdb->escape( $array ); } return $array; }
If you do not like editing (and re-editing after each upgrade until 3.1!) then the longer answer as I have noted before, AND assuming you do not need the data anymore, is to remove the user-meta that was created by the plugin (You’d need phpmyadmin).
In the DB, in the user-meta table, find all the meta keys that belong to the deactivated plugin and delete them for all your users!
V2.3, widget, public user lists
By · CommentsVersion 2.3 has just been uploaded. It offers the following:
Widget
- the beginnings of a widget to display any user list you wish in your sidebar such as ‘top posters’, ‘top commenters’, longest members, newest members etc. It is a “beginning” as improvements in the mechanism and features is required for this to be truly useful.
Privacy control
Lists can now be flagged as ‘public’. This will allow that list to be displayed in a shortcode or widget publicly. If a list is not public, it will only be viewable by a logged in user with either ‘list-users’ or ‘edit-users’ capabilities.
For more changes see the changelog
Debugging your setup of amr-personalise
By · CommentsIf you are not getting the desired output (perhaps it is blank?), then check the following:
Pages/post – Not logged In:
Is the default text for user name configured in the settings ? If not and you are not logged in, the you will see nothing (ie no output, or empty string output).
Pages/post – Logged in
Does the user you have logged in with actually have user profile data? If there is no name data, then it too may show blank. If there is a blank string stored in the database, then it may bring that up. A newer version (2.3) will check for blank strings. So for 2.3 up it will show at least (if no other data) the nick_name (as that is a required wp field) or user_login or email
Emails – must be sending to 1 user at a time
Since a user is not logged in when an email is sent, the only other way to determine the individual user is by the email recipient. Therefore emails must be configured by whatever plugin you are using, to send one email per user. Bulk multi-destination emails cannot work.
Message feature or not?
If you are using the message feature and one of the fields has no data, then the message will not display at all.
EG: if the user has not entered a bio, then a shortcode with a message as below, will return nothing:
user message=”Your bio: %s ” user_description
If the shortcode however uses:
user user_description
then if there is no bio, the words user_description will be shown (from v 2.3 up).
If you have a complicated message, please break it down into multiple messages that can standalone, so if one piece of data is missing, you will not lose the whole message.
Misspellings (or wordpress has changed the metakey name)
Please also check that the meta key you are attempting to use is correctly spelled (check the database if you can).
Exporting a wordpress user list to a csv file
By · CommentsA number of people using the amr-users plugin and who are Excel users, seem to need help when it comes to importing the csv file into excel. Open Office and Google Docs users seem to be fine.
As far as I can make out, this seems to be because:
- their default excel csv import settings do not match the csv file settings (comma separated, and all fields double quotes delimited – this is a standard csv usage.)
- they do not know how to get to the text import wizard (Office 2007 in particular is non obvious)

CSV Text Import Screen 2
Office 2007
In Office 2007, it seems that the trick is to rename the file to a .txt file, instead of a .csv. Excel 2007 should then automatically load the text import wizard. You may find other benefits to, in being able to define how excel should handle the data in each column.
Note: When Excel opens a .csv file, it uses the current default data format settings to interpret how to import each column of data. If you want more flexibility in converting columns to different data formats, you can use the Import Text Wizard. For example, the format of a data column in the .csv file may be MDY, but Excel’s default data format is YMD, or you want to convert a column of numbers that contains leading zeros to text so you can preserve the leading zeros. To run the Import Text Wizard, you can change the file name extension from .csv to .txt before you open it…
Using the Excel Text Import Wizard:
Get the text import wizard up
- either opening from the menus (Office 2003 – Click Data → Get External Data) or
- by renaming file to a .txt (Offfice 2007) and then double clicking on it
- Choose delimited, Click next
- Choose Delimiter: comma
- Choose text qualifier: “, Click next,
- Other options as you wish
- Click Finish
Other resources:
- Microsoft help is here.
- Help with screen shots of the text import procedure
- If you prefer being able to follow a video, this one may be helpful: http://www.auditexcel.co.za/Import-Data.html
Comment totals by authors
By · CommentsThe comments totals and potential link to comment/author archive in the user list plugin has temporarily been removed. I was working with people who had large numbers of users users and there are a number of problems with providing the comments totals and link to comment/author archive, and rather than provided a half baked solution, I decided to remove the option for now. I did not clean it out of the example report thoroughly enough, so some people wondered whether there is a bug.
Problems with providing Comment Totals
- Getting comment totals is potentially very slow
- Comments can be made by people with no userids (not registered) – the plugin does not yet cope with that.
- The comments link was using the “comments by author” list done by Lester’s Wp-stats plugin – there is no wordpress archive that lists comments for an author (authors yes, comments yes, but not the intersection of the two). So you had to have that plugin activated and the stats url option saved in your db (see wp-stats settings). Or else I’d have to write some comments_by_author template.
- The standard wordpress template tag does not expect one to query by author. See http://codex.wordpress.org/Template_Tags/wp_list_comments. So I’d have to write one – not done yet.
You want it back anyway?
If you desperately want the comment totals back before I figure out a better way to do it, then in file ameta-list.php, round about lines 299 to 303, change the comment_count code to the following:
case 'comment_count': { /* if they have wp stats plugin enabled */
if ((empty($v)) or (!($stats_url = get_option('stats_url')))) return($v);
else return( '<a href="'.add_query_arg('stats_author',$u->user_login, $stats_url).'">'.$v.'</a>');
break;
}
Register Plus and User Lists
By · CommentsRegister-plus is a very useful plugin. However Dieter Eerens, and I have discovered a situation where it does not play nicely with my user lists plugin. (Well it also highlighted a bug in my plugin for users on php <5.3, so make sure you have plugin version 2.1 which gets around this!)
What it does…
If one create a custom field of the checkbox type with multiple comma separated extra values, these are stored in your wp user meta table as a string:
Nested user meta data
Now my plugin does it’s best to handle nested user meta data – it checks for arrays and objects and breaks those down into single level values so you can report and filter by them. Ideally of course each piece of user data should be stored simply as single value! However some plugin authors don’t seem keen to do it that way.
Comma’s in user meta strings
A comma in a user meta string is quite a valid thing – maybe it’s a descriptive field? So the user list plugin which has to work generically, since it does not know what fields people will be creating, cannot just breakdown any string into comma separated components …..
So if you need to create fields using Register Plus for your users where they may “belong” to more than one of the values AND you want to be able to filter or list by those values using my plugin, then you will need to define more than one field! (Eg: the example given was that a person could be a coach and a player, or just one.)
Two possibilities are shown below:
The database (user meta table)
The list:
You’d have to play around with names and values to see what works best from a usability point of view!
Or ask Skullbit/Devbits to update the plugin and change how those values are stored – single user meta values might be better, or at least an array!
User Lists or Reports for Large Membership sites
By · CommentsVersion 2 of the amr users plugin has been uploaded to wordpress. It is a fairly major change aimed at better performance for websites with a large number of users, so a lot of the additional functionality is around cacheing the reports and rebuilding the caches when there are user changes.
This was released now as a number of folks asked about it. I hope to put a few more updates through soon to address the following:
- Ability to reference additional user tables (eg: subscribe 2 un registered users)
- Cached reports are updated on standard wordpress changes, however once one starts accessing additional tables where there is no ‘action’ defined by which one could trigger an update, then we may need to have a regular background cache update.
Don’t blame 2.9!
A site was hacked. This was only detected because he had a funny admin screen so decided to do auto upgrade to 2.9 (possibly without backup!). This appeared to cause his plugins to dissappear including the one that protected his content! This may help others, as initial googling did not find direct answers.
Imperatives for any site!
Ability to recreate your site – this means
- keeping clean copies of any premium themes and plugins, as well as a database backup. The wordpress files and free plugins can be re downloaded
- most good hosts will do a daily backup – know how to call on them if you have to – at most you may lose one day of posts or registrations. Worst case you export the possibly hacked DB and files in case you need to carefully extract any updates before they restore the older version of your site!
Ability to detect a problem
- See some notes here http://webdesign.anmari.com/check-if-youve-been-hacked/
Symptoms:
- “funny admin screen” under 2.8.4
- on upgrade to 2.9 – plugins appeared “lost” – invalid header message on upgrade. Maybe 2.9 detecting the bad code?
Upon investigation
WordPress files
- At top wp level, found BAD file: shermie_helsa.php – with eval base 64 code.
- Config file was hacked too
- did spot checks and hold thumbs, seems clean – worry is DB?
- At top wp level, found BAD file: shermie_helsa.php – with eval base 64 code – Deleted it
- Config file was hacked too
Themes
- All top level files of themes hacked too – probably the script just adds itself to all the files.
- Tried to clean up – very badly hacked though – everywhere – looks like bad javascript too!
- Saved BAD themes to a somehackedfiles at top level via godaddy – DO NOT click on or RUN from BROWSER. Delete if you no longer need them.
- Loaded a clean default theme.
- Got clean cutline from http://cutline.tubetorial.com/cutline-3-column-theme-now-available/
- copied over tailored images – edited header.php to use your images – hope that was the only custom change made!
Plugins
- same as themes – hack must run through all such files
- copied to the hacked files
- downloaded new versions
- copied my version of ym – I don’t have yminder locally yet – do you have a clean copy – else download later
- ADDED:
- login lockdown (helps prevent bruteforce hacking into your system)
- wp-db-backup (no backups were available)
WordPress DB
- browsed through the options (apparently some hacks hide there – did not see any thing obviously wrong there….)
Other useful posts:
Minor fixes for older wordpress and hasty configurers
By · CommentsVersion 1.4.5 recently uploaded to wordpress has two minor changes:
- For hasty configurers who do not configure the nice names for the list headings, the earlier version would fail on attempting to configure a list without first configuring nicenames. 1.4.5 will check and use default nicenames.
- For versions of wordpress < 2.8 (and note still greater than or equal to 2.7) the rss feed for updates such as this one about the plugin would fail as it uses function fetch_feed which is new in 2.8. Alternate logic has been provided.

















