Advertisement:

Author Topic: Redirect to main page  (Read 4754 times)

naneri

  • Newbie
  • *
  • Posts: 28
Redirect to main page
« on: March 24, 2014, 08:58:57 pm »
How do i redirect users to the main page after login?
I don't want them to redirect to login page, cause they might not notice that they have logged in.

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Redirect to main page
« Reply #1 on: March 24, 2014, 09:24:36 pm »
IMO after FB login it should redirect to account page so the rest of the information can be filled out, as well as a chance for premium upsale...but thats just me probably

naneri

  • Newbie
  • *
  • Posts: 28
Re: Redirect to main page
« Reply #2 on: March 24, 2014, 09:55:52 pm »
Ok, how do i make it to redirect to account page (if the user is already registered) instead of staying on the login page?

amoric69

  • Full Member
  • ***
  • Posts: 185
Re: Redirect to main page
« Reply #3 on: April 03, 2014, 11:46:14 am »
Place a button  ;)

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: Redirect to main page
« Reply #4 on: April 06, 2014, 01:55:02 pm »
the answer is modifying this code in base.facebook.php

I don't know how exactly

Code: [Select]
  /**
   * Get a Login URL for use with redirects. By default, full page redirect is
   * assumed. If you are using the generated URL with a window.open() call in
   * JavaScript, you can pass in display=popup as part of the $params.
   *
   * The parameters:
   * - redirect_uri: the url to go to after a successful login
   * - scope: comma separated list of requested extended perms
   *
   * @param array $params Provide custom parameters
   * @return string The URL for the login flow
   */
  public function getLoginUrl($params=array()) {
    $this->establishCSRFTokenState();
    $currentUrl = $this->getCurrentUrl();

    // if 'scope' is passed as an array, convert to comma separated list
    $scopeParams = isset($params['scope']) ? $params['scope'] : null;
    if ($scopeParams && is_array($scopeParams)) {
      $params['scope'] = implode(',', $scopeParams);
    }

    return $this->getUrl(
      'www',
      'dialog/oauth',
      array_merge(array(
                    'client_id' => $this->getAppId(),
                    'redirect_uri' => $currentUrl, // possibly overwritten
                    'state' => $this->state),
                  $params));
  }

  /**
   * Get a Logout URL suitable for use with redirects.
   *
   * The parameters:
   * - next: the url to go to after a successful logout
   *
   * @param array $params Provide custom parameters
   * @return string The URL for the logout flow
   */
  public function getLogoutUrl($params=array()) {
    return $this->getUrl(
      'www',
      'logout.php',
      array_merge(array(
        'next' => $this->getCurrentUrl(),
        'access_token' => $this->getUserAccessToken(),
      ), $params)
    );
  }

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: Redirect to main page
« Reply #5 on: April 06, 2014, 02:27:51 pm »

amoric69

  • Full Member
  • ***
  • Posts: 185
Re: Redirect to main page
« Reply #6 on: April 07, 2014, 02:02:39 pm »
Don't run in 2014

amoric69

  • Full Member
  • ***
  • Posts: 185
Re: Redirect to main page
« Reply #7 on: April 09, 2014, 01:08:49 pm »
With Registered users only plugin, we can redirect users but only if they're not connected.
http://market.osclass.org/plugins/registered-users-only_29
in the index.php :


 <?php   function login_necessary( ) {
        $location   = Rewrite::newInstance()->get_location() ;
        $section    = Rewrite::newInstance()->get_section() ;
       
        switch($location) {
            case('login'):
            case('register'):
            break;
            default:            // message
                                if( !osc_is_web_user_logged_in() ) {
                                    osc_add_flash_info_message(__('Seul les utilisateurs enregistrés peuvent se connecter. Enregistrez un compte ou connectez-vous', 'registered_users_only')) ;
                                    header('Location: ' . osc_register_account_url()) ; exit() ;
                                }
            break;
        }
    }

    osc_register_plugin(osc_plugin_path(__FILE__), '');
    osc_add_hook(osc_plugin_path(__FILE__)."_uninstall", '');

    osc_add_hook('before_html', 'login_necessary');

?>


Is it possible to leave free access to some pages ?

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: Redirect to main page
« Reply #8 on: April 09, 2014, 10:27:08 pm »
you are making it very complicated..

the simple answer is here http://forums.osclass.org/plugins/facebook-connect-redirect-after-login/msg48158/#msg48158

amoric69

  • Full Member
  • ***
  • Posts: 185
Re: Redirect to main page
« Reply #9 on: April 10, 2014, 01:06:23 pm »
Is not the same problem.
With the plugin Registered users only it's possible to limit access to unregistred users. But there is no conditions no configurations
Just free access for some pages, I think it's just a condition :
Is not the same problem.
With the plugin Registered users only it's possible to limit access to unregistred users. But there is no conditions no configurations
Just free access for some pages, I think it's just a condition :
I've tested :
Code: [Select]
    if($_GET["state"]==''){
   header('Location: /index.php' );
   }
It's doesn't run. It return me to the root of site, but my osclass is not at the root, it's in www.mywebsite.com/osclass/index.php and the code is wrong too.

You got an idee ?