Topic-icon Protect link from guests

Active Subscriptions:

None
11 years 6 months ago #48991 by haibar
I have an interesting use case and much of the problem solved from the JReviews people. I think JFBConnect can solve the rest.

Basically, I have the following on many JReviews listings - see screencast.com/t/ByslGXIOV

As you can see - there is a deal available for that JReviews listing with a link for that deal. Right now, it's not protected against guests getting the deal. What I want is to:

1. If the user is logged in, I want to show this link as I currently do
2. If the user is not logged in, I want to show this link, but it instead goes to some JFBConnect (SCLogin?) modal dialog that gets the user to register/login and then continues to the deal link as before (assuming the user successfully registered or logged in

There is a entry point in the JReviews code where I can insert some hook into JFBConnect - that is, I can query to see if my user is a guest or a member. If the user is a member, I can show the link as I do now. If the user is a guest, I would like to pop up a modal to ask the user to login/register via JFBconnect and then it would automatically continue as though the regular member link was clicked (if that's not possible, it would then refresh and show the me page as a member which would have the fully disclosed link).

Any idea how to do this?
The topic has been locked.
Support Specialist
11 years 6 months ago #49003 by mel
Replied by mel on topic Protect link from guests
If you already have the SCLogin module displaying on the page somewhere, you can add some code that will trigger it's popup. You could even put the SCLogin module on the page and use some CSS to hide the normal "Login / Register" buttons that would show, so that you can use it's popup. To do this, you just need to add the following link where the deal would be:
<a class="btn btn-primary" href="#login-modal" role="button" data-toggle="sc-modal">Log in for this link!</a>
If you want to put the SCLogin on the page, but hide it's normal login/register buttons, use the following CSS:
.sourcecoast.sclogin-modal-links.sclogin { display: none;}

Right now though, we don't have a way to set a custom redirection for each instance of the SCLogin module. You can only use "Same Page" or a specific menu item in the JFBConnect component 'New User Redirection' field. It sounds like "Same Page" would work for you in one of your options though.

The other option is to simply check if the user isn't logged in and, if not, add the {JFBCLogin} tag. That will show all the social login icons in the spot of the deal, but it won't show the Joomla login fields (not sure if you need those fields or not). With the {JFBCLogin} tag, you can select to use custom images just for that area as well, if you'd want them to appear differently.

I think this should give you some good suggestions to try out, but please let us know if you need more clarification.

-Melissa
The topic has been locked.