Restrict certain Wordpress pages only to logged in SMF users

Started by palmdoc, October 14, 2018, 08:03:30 AM

Previous topic - Next topic

palmdoc

Greetings awesome SMF gurus

I am quite new to SMF and have been getting very giddy trying to read up on this topic.
I am not looking for a bridge login integration between Wordpress and SMF as I want my user base to be only registered in SMF

Basically what I require is that only certain pages in my Wordpress site are restricted to logged in SMF users.
SMF is in a /forum subdirectory of the same domain where Wordpress is installed

If I use SSI.php how does one use it when loading only certain pages?
Do please help a noob with a step by step guide


Where does one put this code?

<?php
if ($context['user']['is_guest'])
{
ssi_login();
}
else
{
ssi_logout();
}
?>



How does one do it only for specific pages?

Thank you in advance.

I am not sure which thread is relevant but I'm pasting some here for my reference
http://www.simplemachines.org/community/index.php?topic=12936.0
https://www.simplemachines.org/community/index.php?topic=387713.0
https://wiki.simplemachines.org/smf/How_to_use_the_SMF_user_system_outside_of_SMF

Arantor

You basically can't without rewriting SSI, it just doesn't play nice inside WordPress, never has, probably never will... but like SMF, WodPress funnels everything into one place, you can't just edit individual files to adjust individual pages :(

Kindred

Well, there is logic within WordPress to factor the page
In my wordpress installation, I use it to display a widget only on the classifieds page.

In theory, you could do it within a widget...

However, the point about SSI not playing well inside WordPress is still a factor
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

palmdoc

So it wouldn't be any good if I put

<?php require("/home/xxxx/public_html/xxxxx/forum/SSI.php");?>

right at the start of wp-load.php

and

<?php
if ($context['user']['is_guest'])
{
ssi_login();
}
else
{
ssi_logout();
}
?>


in a specific page?

Arantor

Not really, no, because every single post (and page) still flows back under the hood to index.php, meaning that doing so becomes all or nothing, rather than page by page.

palmdoc

Quote from: Kindred on October 14, 2018, 08:31:39 AM
Well, there is logic within WordPress to factor the page
In my wordpress installation, I use it to display a widget only on the classifieds page.

In theory, you could do it within a widget...

However, the point about SSI not playing well inside WordPress is still a factor

How is that done?
Thanks

Arantor

Doing it as a widget doesn't hide the rest of the page...

palmdoc

OK basically I don't want someone coming to a specific page on my Wordpress site without login to SMF first.

So I tried this workaround

1) Install ASPS Check Referer  plugin
http://www.artistscope.com/asps_check_referrer.asp
protect the page URL with referer only from my domain

2) Link to the page using PHP

<?php require("/home/xxx/public_html/xxx/forum/SSI.php");?>
<?php
if ($context['user']['is_guest'])
{
header("HTTP/1.1 301 Redirecting");
header("Location:https://xxx/forum/index.php?action=login
"
);

}
else
{
header("HTTP/1.1 301 Redirecting");
header("Location:https:/xxx/test-page/");
exit();
}
?>



So if one goes directly to https:/xxx//test-page/ or linked from some other domain, it will present a Direct Access not permitted
Only thing is how to pass the Referer from the PHP redirect

Arantor

Given that plenty of security software, and browsers going forward, often don't reveal the referer, and that it's utterly unreliable since it's not hard to spoof it anyway...

Honestly, this is a huge problem, mostly because WordPress has no concept of restricted posts beyond future/draft posts, and the only way to really fix this is a really dirty change inside the Loop (which will be removed next update!), or not putting that content inside WordPress and instead putting it in SMF with one of the mods that can add pages. Or even SSI powered pages, nothing says that content has to actually be in WordPress and if you genuinely need it restricted.

drewactual

one way to pull it off is to use php include of a file that has the WP output you want to share to users, but also requires users to be logged using SMF logic... it becomes an If/Then situation, and uses call to whatever specific WP category posts from 'outside the loop'...

Using CSS file in both WP and SMF, you can display:none the div the WP post shows up in a specific category, only to inline css the same div on the php included file and showing it if users pass the 'user' challenge (they're logged in). 

it's a slippery slope to use trickery, but if you're in a pinch.....

Kindred

except, IIRC, there are actually some collisions between SMF and WordPress variable names
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

drewactual

As sloppy as WP is, I've little problems doing what ive described less using css as a controller whether someone (user/guest) sees it.... Thats the tricky part, but I see no reason it wont work so long as the css that reveals it is inline. There are many different ways to get stuff out of WP outside the loop, and so long as those items are presented (appearingly) inside SMF via pho includes and not hard coded into it, it's not bothered my page at all.

palmdoc

Quote from: drewactual on October 16, 2018, 09:50:08 AM
one way to pull it off is to use php include of a file that has the WP output you want to share to users, but also requires users to be logged using SMF logic... it becomes an If/Then situation, and uses call to whatever specific WP category posts from 'outside the loop'...

Using CSS file in both WP and SMF, you can display:none the div the WP post shows up in a specific category, only to inline css the same div on the php included file and showing it if users pass the 'user' challenge (they're logged in). 

it's a slippery slope to use trickery, but if you're in a pinch.....

Some example code for a noob would be much appreciated  8)

Advertisement: