Recent Topics

1 Jan 13, 2015 10:07    

Hi all,
I would like to restrict access to one of my blogs to registered members only.
Can someone explain what I need to do to force a user to have to login to be able to view the blog?

I searched through the forum but most of the information I found seems to be outdated.

EDIT:
Okay, I figured out that if I add $login_required='true' to the top of my blog php file(blog3.php), the user does have to login.

What I have is a custom php script that I want to use for the front page of my blog.
I want the users to have to login to see the page generated by the script but I don't want them to have to go to the blog3.php file to login.
I would like to have the login displayed if they are not logged in when they navigate to the custom php file, which is not in the blog system
but in another section of my site.

I have configured the front page of the blog to be the custom php script but in order to log in, currently the users would have to use blog3.php.

Is there a way to hook the script into the blog system so I can display login/logout links controlled by the blog system?

Thanks,
Vital-eMedia

2 Jan 13, 2015 12:34

Hi
Can't quite understand

What I have is a custom php script that I want to use for the front page of my blog.
I want the users to have to login to see the page generated by the script


You have a custom page for the front page but you want a login before it can be accessed, so you want the login to be on the screen first.

But you don't want to use http://***your_domia.***uk/blog3.php?disp=login&redirect_to=%2Felf.php%3Fdisp%3Dposts&source=menu%20link to log in, why???

I would like to have the login displayed if they are not logged in when they navigate to the custom php file, which is not in the blog system
but in another section of my site.

So if someone is on blog3, then and only then you want them to have to log in to the custom page.

If it is just a single page then presumably the main content is accessible after that.

If the main content thereafter is another independent site, why not just add your own custom login on the custom page?

You can use the same login details presumably by linking to the blog database, if that is what you want

Am I getting close to understanding you problem

3 Jan 13, 2015 15:35

Hi,
it would a great help do get information about your system/b2evo version. So help would be easier.

You can decide at posting, if the post should be readable for all, for community or for members (3 of a lot of possibilities). If you post it only for community or members, people need to login for reading. If they don't do it, they will see an empty page with the information "There is nothing to show here".

So you can force a login for reading the posts.

5 Jan 13, 2015 19:17

@amoun,

Thanks for replying.

You have a custom page for the front page but you want a login before it can be accessed, so you want the login to be on the screen first.

But you don't want to use http://***your_domia.***uk/blog3.php?disp=login&redirect_to=%2Felf.php%3Fdisp%3Dposts&source=menu%20link to log in, why???

I want to hide the fact that it is a part of my blog.

So if someone is on blog3, then and only then you want them to have to log in to the custom page.

If it is just a single page then presumably the main content is accessible after that.

If the main content thereafter is another independent site, why not just add your own custom login on the custom page?

You can use the same login details presumably by linking to the blog database, if that is what you want

Am I getting close to understanding you problem

That's pretty much correct.
I want to add a custom login but be able to mange users form the blog system.
Any pointers on where I can look for clues to implement this?
I don't want to have a whole other system to log in to the custom php page.

Thanks,
Vital-eMedia

6 Jan 13, 2015 19:30

@ednong,
Thanks for replying.

it would a great help do get information about your system/b2evo version. So help would be easier.

I'm running b2evolution version 5.2.0. on a Windows 7 system using apache 2.2, php 5.4.34 and MySQL Server 5.5

You can decide at posting, if the post should be readable for all, for community or for members (3 of a lot of possibilities). If you post it only for community or members, people need to login for reading. If they don't do it, they will see an empty page with the information "There is nothing to show here".

So you can force a login for reading the posts.

There aren't actually going to be any posts made to this 'blog'.
It's actually a Facebook application that I want to only allow members access to.

More Information you will find in this manual - http://b2evolution.net/man/user-guide/adding-content/how-to-add-content .

In the Image, it is the section "Visibility/Sharing" where you can decide it.

Thank you for that information but i understand how to add posts. :)

Thanks,
Vital-eMedia

7 Jan 13, 2015 21:26

Hello,

@vitalemedia I think that I understood what you need, so let me try a simple three steps solution.

1) We will use the in-skin login form feature to emulate the "external" login page. In order to do that, just duplicate the file /skins/_login.disp.php into your skin's folder, but renaming it to login.main.php. This way you will have a clean but fully functional login form just waiting for the addition of the look&feel of your site. You can test it by going to http://yourdomain.com/blog3.php?disp=login&redirect_to=%2Fi6%2Fblog3.php. There is only a little modification that you need to do to this file:

Find a line like this (in my case it's line 22 because this example is based on the evoPress skin):


echo '<p>'.T_('You are already logged in').'</p>';

and replace it with:


header_redirect( $baseurl );

Note: the appropriate redirections could be a future step.

2) As you want to use the $login_required variable, the previous step wont work because b2evolution will load the original _login.disp.php file, so you need to go to the index.main.php file of your skin and manage that load according the case. Just after the skin_init( $disp ); line, you will need a conditional like this:


skin_init( $disp );

if( $disp == 'login' && $login_required )
{
	skin_include( 'login.main.php' );
}
else
{

Please check this link: https://gist.github.com/mgsolipa/6d3be62add53a87516b2, there is the index.main.php file that I modified, just compare it against the original one included in your site and figure out where to make your own modifications. Remember that I used evoPress, so you need to compare with the same file and adapt to your own skin.

3) Finally, the "external" page. You can use a stub file and apply your design to it. Just duplicate the file blog3.php and name it as you want, let's say "custom_login.php". This file could be placed in any folder, just remember that it can't be outside the blog's root folder, and also that the line require_once dirname(__FILE__).'/conf/_config.php'; should be pointed accordingly.

Now, if you want to go directly to the login form, try this URL: http://yourdomain.com/custom_login.php?disp=login

I know that this could be improved ad-infinitum, but it's a starting point, at least. Also, I tried to be as clear as possible, however, any question, or mistake that I made here (almost sure), please tell me.

Regards!

8 Jan 14, 2015 02:46

Hi,

I would like to restrict access to one of my blogs to registered members only.
Can someone explain what I need to do to force a user to have to login to be able to view the blog?

Thank you for that information but i understand how to add posts. &#58;&#41;

ok, so I don't understand really what you want. Sorry ;)

I guess, you place a link on facebook to this invisible blog, isn't it?


Form is loading...