Username in url?!?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Username in url?!?

Post by jmansa »

Is it possible to make a "page" which is named by the username loged in? Example. If a user logs he or she should be redirected to a page called "index.php?page=username"... Can this be done?
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Username in url?!?

Post by Dee »

The FrontendUsers module has a returnto parameter you can use for that, from the module help:
# (optional) returnto="page"

Used with the login, logout, and changesettings forms, this parameter contains the page id or alias of a page to redirect to, when the form has been successfully completed
Regards,
D
Zoorlat

Re: Username in url?!?

Post by Zoorlat »

... and in the returnto property Dee mentions, you can assign $customcontent_loginname. This of course assumes that a page with a matching page alias already exists.

Then, to make it even more secure, you can use something like this in your page template:

Code: Select all

{if $ccuser->loggedin() && $customcontent_loginname eq $page_alias }
   {content}
{else}
   Please log in.
{/if}
If you want the page automatically created upon user creation, I think it is more difficult.
See this thread for more info: http://forum.cmsmadesimple.org/index.php?topic=19152.0;prev_next=prev
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Re: Username in url?!?

Post by jmansa »

That allmost did the job, but... Isn't it possible to make 1 dynamic page called ex. "username", and then when a user logs in it changes to the username of the user. In that way I only have to create on page instead of many new pages???
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Username in url?!?

Post by jmcgin51 »

It sounds like you want to reassign the page alias based on the username of the logged in user, which I don't think is possible (or at least not practical).

If you only want to create one page, then just create one page and have all the users directed to that page after login.  If you want different content on that page, based on the logged in user, you could probably do something with content blocks and a little Smarty magic.
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Re: Username in url?!?

Post by jmansa »

I might end up doing so, but what I want to do is to make a littke community site where each user has a page showned to others with blogs, gallery, etc. etc. and it would be nice if they could teel there friends to go to "www.site.com/username". But this might not be possible???
Post Reply

Return to “Developers Discussion”