Ultimate Facebook - Redirect Upon Login (To/From Specific Pages)

I have a multisite setup with Ultimate FB installed. I have set up the plugin to redirect members to a member account area upon logging in.

For one specific page where visitors can log in, I want it to redirect the user to a submission page. Is there a shortcode attribute that allows me to specify a redirect override?

  • Vaughan
    • Support/SLS MockingJay

    Hi chris,

    Hope you're well?

    There isn't anything like that i'm afraid, though we could perhaps accomplish this with a custom filter.

    Can you give me the page URL of the page where you want this redirect to be different, and also the URL of the page you want it redirected to & i'll see if I can give you some custom code to accomplish this.

    Thanks

  • Chris
    • The Bug Hunter

    HI Vaughan,

    That would be great. The FB plugin currently sends all visitors to /member-area/.

    For this scenario, here are the From & To links:

    FROM - Login Page where I want to add the redirect - /add-a-book/
    TO - Visitors clicking FB button on /add-a-book/ will be sent to - /submit-a-book/

    Thanks,
    Chris

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    Can you try the following;

    Create a file called wpmudev_ufb_custom_login_redirect.php

    Place the following code in this file.

    <?php
    add_filter( 'wdfb-login-redirect_url', 'wpmudev_ufb_login_redirect' );
    function wpmudev_ufb_login_redirect($redirect_url) {
    
        $page = str_replace('/', '', $_SERVER['REQUEST_URI']);
    
        switch($page) {
            case 'nf-login':
                return site_url('/add-a-book/');
                break;
    
            case 'add-a-book':
                return site_url('/submit-a-book/');
                break;
    
            default:
                return $redirect_url;
                break;
        }
    }

    Now upload this file to /wp-content/mu-plugins/

    If mu-plugins folder doesn't exist, create it first.

    Hopefully now, when on your nf_login page, the FB redirect_url should redirect to the /add-a-book/ page

    When on the add-a-book page, it should redirect to submit-a-book

    Hope this helps

  • Chris
    • The Bug Hunter

    Hi Vaughan,

    Thanks for this! I think there might be some miscommunication:

    Hopefully now, when on your nf_login page, the FB redirect_url should redirect to the /add-a-book/ page

    I am looking for it to do the following:

    "when on your /add-a-book/ page, the FB redirect_url should redirect to the /submit-a-book/ page"

    So, this custom redirect should only occur if the person clicks Connect with FB from the /add-a-book/ page. Hopefully, that clarifies things.

    Thanks,
    Chris

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    Apologies.

    Try the following code.

    <?php
    add_filter( 'wdfb-login-redirect_url', 'wpmudev_ufb_login_redirect' );
    function wpmudev_ufb_login_redirect($redirect_url) {
    
        $page = str_replace('/', '', $_SERVER['REQUEST_URI']);
    
        switch($page) {
            case 'add-a-book':
                return site_url('/submit-a-book/');
                break;
    
            default:
                return $redirect_url;
                break;
        }
    }

    Hope this helps

  • Vaughan
    • Support/SLS MockingJay

    Hi Chris,

    <?php
    add_filter( 'wdfb-login-redirect_url', 'wpmudev_ufb_login_redirect' );
    function wpmudev_ufb_login_redirect($redirect_url) {
    
        $page = is_single() ? 'post' : str_replace('/', '', $_SERVER['REQUEST_URI']);
    
        switch($page) {
            case 'add-a-book':
                return site_url('/submit-a-book/');
                break;
    
            case 'post':
                return '';
                break;
    
            default:
                return $redirect_url;
                break;
        }
    }

    Try that, not sure if it will work though.

    Hope this helps

  • Chris
    • The Bug Hunter

    Hi Vaughan,

    I made a slight modification and added it as a separate filter (below). It works, but I have another question:

    I would also like to add a 'name' attribute to the return url (below) without disturbing the post's path.

    return site_url('/#scroll-down-page');

    Any idea how I could do that?

    Thanks,
    Chris

    Modified Code:

    add_filter( 'wdfb-login-redirect_url', 'single_post_login_redirect' );
    function single_post_login_redirect($redirect_url) {
    
        $page = is_single() ? 'post' : str_replace('/', '', $_SERVER['REQUEST_URI']);
    
        switch($page) {
            case 'post':
                return '';
                break;
    
            default:
                return $redirect_url;
                break;
        }
    }
  • Chris
    • The Bug Hunter

    Hi Vaughan,

    The problem is that this login button will be added to each post, which all have different slugs. I need the visitor to be returned to the page where they are logging in from and directed to the name anchor (e.g. #scroll-down-page). Is it possible to create something like the following?

    return 'http://yourdomain.com/(.*)#scroll-down-page')';

    I'm not sure what would be appropriate here.

    Thanks,
    Chris

  • Vaughan
    • Support/SLS MockingJay

    Hi chris,

    so something like this?

    add_filter( 'wdfb-login-redirect_url', 'single_post_login_redirect' );
    function single_post_login_redirect($redirect_url) {
        $page = str_replace('/', '', $_SERVER['REQUEST_URI']);
    
        switch($page) {
                default: // if single post, then return to current page url with scroll-down-page
                    $redirect_url = is_single() ? site_url("/{$page}/#scroll-down-page") : $redirect_url;
    
                    return $redirect_url;
                break;
        }
    }

    Hope this helps

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.