[Resolved] Search for registered user only

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
2
18
Re: Search for registered user only

Currently there is no option to enable this for only registered users. It enables search globally. You can tweak the code and use if statement to show search only for users who are logged in....
 

black-serv6502

New Member
YetiShare User
Apr 2, 2017
19
0
0
Re: Search for registered user only

Ok thank you.

Will you have a piece of code proposed because I am not a great php expert.

thank you in advance.
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
2
18
Re: Search for registered user only

something like below in your search.html file. Please test it on test server first. use at your own risk.

Instead of
if(SITE_CONFIG_ENABLE_FILE_SEARCH == 'no')
{
// this page can not be accessed
coreFunctions::eek:utput404();
}

Use

if(SITE_CONFIG_ENABLE_FILE_SEARCH == 'no')
{
// this page can not be accessed
coreFunctions::eek:utput404();
}
elseif ($Auth->loggedIn() == false)
{
// this page can not be accessed
coreFunctions::eek:utput404();
}
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
2
18
Re: Search for registered user only

what do you get? an error? i am not that good with the code, i can copy and paste and get it to work by trial and error..
 

black-serv6502

New Member
YetiShare User
Apr 2, 2017
19
0
0
Re: Search for registered user only

In fact it's good it works well :)
But is it possible that when the unregistered person clicks on it is redirecting to the login page?
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
2
18
Re: Search for registered user only

Great!!
To redirect to login page, instead of coreFunctions::eek:utput404();
use
coreFunctions::redirect(WEB_ROOT . "/login." . SITE_CONFIG_PAGE_EXTENSION);