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 "Memebrs Only" landing page message | Forum

Ryan P
Ryan P Aug 13 '16
Hey everyone,

I want to add a custom message for visitors when  attempting to view "members only" content. The default is "you are not authorized...etc", & I understand that can be changed in "languages" in the admin dashboard.

What I want is a custom message for one specific page, not a universal message. So instead, it would read "you are not authorized to view the forum section unless logged in". Then, the same for other pages but replacing "forum" with other sections that are members only ("blogs", custom page, etc).

Is this possible?
Darryl B Leader
Darryl B Aug 13 '16
That would have to be done with a plugin. There was a post on here about how to create a floatbox with a message, but it would have to be tied to the user role access, and the menu. (ex. When they click a menu item, and go to a page the float box with an overlay background would pop up with the message after page load).
Ryan P
Ryan P Aug 14 '16
Thanks Darryl. I've already added
 if ( !OW::getUser()->isAuthenticated() )
throw new AuthenticateException();

to some custom public pages I have, which requires the user to join as seen here: http://www.rotolineups.com/optimallineup

If a dev is available, is there any way to modify the above code to show a custom message? Thanks

Darryl B Leader
Darryl B Aug 14 '16
Dave, or Ebenezer may have info. Coding isn't my thing. I know barely enough html to be dangerous.
dave Leader
dave Aug 14 '16
first you would have to find the text message you want in the lang section or create one yourself in the base section.   Then you could do this 

 if ( !OW::getUser()->isAuthenticated() )
OW::getFeedback()->error($language->text('base', 'special_message_user'));


what this does is it shows that bar on the screen to give the user a message. 

error is a red bar

info is a green bar

warning is a orange bar

base is where you created the language, if its somewhere else then put that instead

special_message_user is the name of your lang key use underscores to make it more readable, you can call it whatever you want just dont make it too long

return keeps them out of the page 

you can replace the return with a redirect if you know the page you want to send them too instead. 

in that case replace the return with this 

$this->redirect(OW::getRouter()->urlForRoute('THE PAGE NAME.index'));

THE PAGE NAME is the name of the page that is created in the init file route for the page you want to send them to, so you would need to check a init file for base to get that page name or find an example somewhere and get the name off that. 

Hope that helps. 

ross Team
ross Aug 15 '16
Topic was moved from General Questions.