Hi all,
I’m having a little trouble writing a fairly simple plugin that handles redirects, and would love some help.
Basically, I’m trying to create short user URLs by redirecting site.com/username to site.com/viewprofile?username. I’m doing this by triggering the plugin on the OnPageNotFound system event, but what I can’t figure out is how to test if the URI entered is a valid user. All of these users will be part of a user group called "Members," so i can test against that, if it helps. Here’s a simplified version of what I have so far:
<?php
$search = $_SERVER['REQUEST_URI'];
$search = ltrim($search,'/');
if ($search) {
if ($search == 'sitemember') {
$modx->sendRedirect('viewprofile?user='.$search);
}
}
return;
The "($search == ’sitemember’)" bit is obviously the spot I can’t figure out. Can I use something like getObject(’modUser’), and if so, can someone show me the correct syntax? Otherwise, $user->isMember(’Members’) seems like it could work, but that seems like it only works for the current user.
Thanks for the help!