Topic-icon Restricted Content or page for register user

Active Subscriptions:

None
12 years 1 month ago #43669 by farkab
Hi, What I am trying to do is to restrict or lock a content page for registered users . If anyone try to access that restricted page if the user is already registered and logged in , he can see , but if the user is not registered or logged in , he will be through to facebook page "display=page" instead of display=popup and once he is login or complete the permission will be redirect to restricted page or content..

I have disable joomla registration completely .. and I am only using facebook api to register user. How I can achive this . Please advice.
The topic has been locked.
Active Subscriptions:

None
12 years 1 month ago #43670 by farkab
Ok I have figured out display=page instead display=popup . it's already there... my mistake i didnt see that.. Now I have figured out how I can restricted menu item and content for registered users and when that page will be accessed ... unregister or not logged in user will be send to facebook page to login or to grant permission. Please show me some idea how I can do that.
The topic has been locked.
Active Subscriptions:

None
12 years 1 month ago #43677 by ferkab
Ok have figured out how to have this feature... If anyone has better suggestion please give... what i have did, use a small jqurery script to trigger a click id#sc_fblogin ....to trigger click add the following code

jQuery(document).ready(function() {
   $(\'#sc_fblogin\').click();
});

to add in joomla 3.0 you can use jDocument addScriptDeclaration . If you have better alternative.. You can tell me .. or you like to do whatever I am doing .. You can use the above code for quick alternative.
The topic has been locked.
Support Specialist
12 years 1 month ago #43683 by alzander
If you're trying to force the user to login using Facebook to see the content, the above should work. The code above looks like it would trigger whenever the user visits the page, not just when they click on a registered menu item though.. so make sure that works how you want.

The above also assumes that the SCLogin module is displayed on the current page. You could likely update the code to:
jQuery(document).ready(function() { 
   jfbc.login.provider('facebook');
});
That may help with a few things, since it's not telling the browser the user clicked when they really didn't.. which some browsers try to block. It also doesn't require the SCLogin module to be displayed somewhere on the page.

I hope that helps, but if you have any questions or need more help, just let me know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 1 month ago #43692 by farkab
After I use your code, it became a loop and browser is spining back and forth... I like to know is there any way I can do it through php... I like that would a better and stable option instead of using javascript. Please help me if possible.
The topic has been locked.
Active Subscriptions:

None
12 years 1 month ago #43693 by farkab
I have figured out why your code is doing dancing .. because every time document is ready it's trigger jfbc.login.provider('facebook'); ... but mine one once logged in #sc_fblogin disappear .. so stop calling it.. but as you said some browser could block it. and I am suspecting google might blacklist thinking as invisible click ... So if possible if advice how I can achieve this with php ...
The topic has been locked.
Active Subscriptions:

None
12 years 1 month ago #43695 by farkab
Ok Now I use
require_once JPATH_ROOT.'/components/com_jfbconnect/libraries/facebook.php';
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();

if ($jfbcLibrary->getMappedFbUserId()){
}else{
Then You javascript function
}

What do you think .. this is would be good ...
The topic has been locked.
Active Subscriptions:

None
12 years 1 month ago #43702 by farkab
Is it possible to fire jfbc.login.provider('facebook'); before document is ready... becuase I tried just jfbc.login.provider('facebook'); on the above code.. it didnt fire... so I am looking for some option to fire login check before the page load .. if possible please help.. Thanks in advance.. or do something completely with sever-side without using javascript.
The topic has been locked.
Support Specialist
12 years 1 month ago #43706 by alzander
The following PHP should do what you're looking for:
if ( !JFBCFactory::provider('facebook')->getMappedUserId() )
{ 
  $uri = JURI::getInstance();
  $returnUrl = $uri->toString(array('path', 'query'));
  JFactory::getApplication()->redirect('index.php?option=com_jfbconnect&task=authenticate.login&provider=facebook&return=' . $returnUrl;
}
else
{
  // Do something
}
That code will automatically redirect the user to the Facebook login area if they are not authenticated with Facebook. They won't even see the page show a little bit first, so be sure that's what you want to happen.

I hope that helps get you going, but if not, or you have any questions, just let me know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 1 month ago #43753 by farkab
Thanks for the help .. I really appreciated it.. After the small fix of closing bracket I have placed your code.. but unfortunately code is having redirect problem after login in facebook. After logged in ... it redirecting a 404 page, I dont know why is happening. Little help will be appreciated.
The topic has been locked.