How to make email permission required when logging in/signing up a user using the FB login? How to make email permission required when logging in/signing up a user using the FB login? codeigniter codeigniter

How to make email permission required when logging in/signing up a user using the FB login?


You should check the received Access Token before you continue with your application logic. How to do this is described here:

https://developers.facebook.com/docs/facebook-login/permissions/v2.0#checking

If you then recognize that the User didn't give the email permission, you can resend him to the permission dialog as described here:

https://developers.facebook.com/docs/facebook-login/permissions/v2.0#handling

Quote:

If someone has declined a permission for your app, the login dialog won't let your app re-request the permission unless you pass auth_type=rerequest along with your request.


using facebook php sdk

require_once 'facebook-sdk/facebook.php';$config = array (        'appId' => 'your id',        'secret' => 'your secret',        'fileUpload' => false,        'allowSignedRequest' => false);$facebook = new Facebook ( $config );$fb_user_id = $facebook->getUser ();$fb_params = array (        'scope' => 'email, publish_stream');

and generate login url for your users

if (empty ( $fb_user_id )) {    $fb_login_url = $facebook->getLoginUrl ( $fb_params );}