We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Custom Profile URL based on username? | Forum

Tina Rodriguez
Tina Rodriguez Oct 11 '15
Hello there! 


I've been trying to mess around with init.php with no luck.


I'm trying to accomplish the following:


Keep all user profile urls at the default setting 

(user/:username)


EXCEPT if the usernames are "Admin" and "Bob" for example.




Ie.


if($username == "Admin" || $username == "Bob")

{

only display THESE profiles as ':/username' instead of 'user:/username' for everyone

}

else

{

display every other profile as 'user:/username' for everyone

}



Can anyone help???

Thank you!! :))

Michael Kearney
Michael Kearney Oct 12 '15
grep -r ":user" /home/user/oxwall

/home/user/oxwall/ow_system_plugins/base/init.php

download the skeleton plugin ---->

OW::getRouter()->addRoute(new OW_Route('skeleton-widgets-delete', 'skeleton/widgets/delete/:id', 'SKELETON_CTRL_Widgets', 'delete'));

:id to :user are similar functions, I woulden't do it... deleteById is found in 30 other functions. 

grep -r "deleteById" /home/user/oxwall

Please look at line 142:  /home/user/oxwall/ow_core/base_dao.php

    public function deleteById( $id )
    {
        $id = (int) $id;
        if ( $id > 0 )
        {
            $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE `id` = ?';
            $result = $this->dbo->delete($sql, array($id));
            $this->clearCache();
            return $result;
        }

        return 0;
    }


The Forum post is edited by Michael Kearney Oct 13 '15
Michael Kearney
Michael Kearney Oct 13 '15
This works lol ...
--------------------------------------------------------------
/home/user/oxwall/.htaccess:

RewriteCond %{REQUEST_URI} !/Admin
RewriteCond %{REQUEST_URI} !/Bob

--------------------------------------------------------------

this will not:

/home/user/oxwall/ow_system_plugins/base/init.php

$router->addRoute(new OW_Route('base_user_profile', 'Admin', 'BASE_CTRL_ComponentPanel', 'profile');
$router->addRoute(new OW_Route('base_user_profile', 'Bob', 'BASE_CTRL_ComponentPanel', 'profile');

this will also work:

-------------------------------------------------------------

/home/user/oxwall/ow_system_plugins/base/init.php

$router->addRoute(new OW_Route('base_user_profile', 'Admin/admin.php', 'BASE_CTRL_ComponentPanel', 'profile');

/home/user/oxwall/.htaccess:

RewriteCond %{REQUEST_URI} !/Admin/admin\.php

-----------------------------------------------------------------




The Forum post is edited by Michael Kearney Oct 13 '15
Tina Rodriguez
Tina Rodriguez Oct 14 '15
Hi there! :)) 


Thanks for the help! 

No luck with Bob though... I'm mainly looking for a method to just take certain usernames and make their profiles have the url

website.com/Bob, website.com/Jimmy, website.com/Michael


and everyone else have the regular

website.com/user/UsernameHere

Michael Kearney
Michael Kearney Oct 15 '15
Let it be known then that, Bob, Jimmy and Michael are exclusionary, maybe... poltergeist. lol

/home/user/oxwall/.htaccess:

Redirect 301 /Bob   http://www.weedbox.net/user/Bob
Redirect 301 /Jimmy   http://www.weedbox.net/user/Jimmy
Redirect 301 /Michael   http://www.weedbox.net/user/Michael
The Forum post is edited by Michael Kearney Oct 15 '15
Tina Rodriguez
Tina Rodriguez Oct 15 '15
lol! Oh the redirect works great! Thank you! :)) 


It's just that the profiles themselves at "website.com/Bob" throw a Page not found error :/