Invision Community has a rich set of member filters behind the core/MemberFilter extension point: group, join date, last visit, content count, reputation, achievements, profile fields, and from Commerce, purchases, subscriptions, total spend and donations. Any application can reuse them instead of writing its own.
There is one trap, and it fails silently.
The trap
Every filter decides for itself which "areas" it is available in, and the list is hardcoded:
// core/MemberFilter/Lastvisit.php return in_array( $area, array( 'bulkmail', 'group_promotions', 'automatic_moderation', 'passwordreset' ) ); // nexus/MemberFilter/Purchases.php return in_array( $area, array( 'bulkmail' ) );
Invent an area name for your own application and every existing filter returns false. You get an empty filter list, with no error anywhere, and you lose exactly the Commerce filters most worth having.
The fix
Ask using 'bulkmail'. It is the only area that returns the full set, and third-party filters work automatically too.
foreach ( Application::allExtensions( 'core', 'MemberFilter', FALSE, 'core' ) as $key => $extension )
{
if ( !$extension->availableIn( 'bulkmail' ) ) { continue; }
if ( empty( $criteria[ $key ] ) ) { continue; }
$clause = $extension->getQueryWhereClause( $criteria[ $key ] );
// documented as returning an array, but several return a bare string
if ( is_string( $clause ) ) { $clause = array( $clause ); }
$where[] = $clause;
$extension->queryCallback( $criteria[ $key ], $query ); // joins
}
If you are sending email
core_members.allow_admin_mails is the opt-out flag, and the core bulk mailer hard-filters on it. Anything sending on an administrator's behalf must too. Unsubscribe already exists at app=core&module=system&controller=unsubscribe, with a key of md5( email . ':' . members_pass_hash ). Reuse it rather than inventing tokens — it invalidates itself on password change.
Recommended Comments