Facebook redirect controlled by URL parameter

I have a feature request for the Ultimate Facebook plugin.

I can setup the login to redirect to a backend url or a site url after facebook login, but I need it to be able to redirect to a url determined by a parameter

On my site, the login page has a parameter in the url like this

?redirect_to=%2Fadd-new%2F

and I would love to be able to specify that parameter in the plugin as an redirect option.

So besides a site / backend option, I would love a site-parameter option, where the plugin will look for the value of a parameter in the url, and if it exists, it will use this as the redirect slug, and if not, it should redirect to a default site url specified in the settings.

  • henrik_gregersen
    • Design Lord, Child of Thor

    I have made the "hack" my self, and if you alter the wdfb_get_login_redirect function in the wdfb_utilities.php file from :

    /**
     * Helper function for getting the login redirect URL.
     */
    function wdfb_get_login_redirect ($force_admin_redirect=false) {
    	$redirect_url = false;
    	$data = Wdfb_OptionsRegistry::get_instance();
    	$url = $data->get_option('wdfb_connect', 'login_redirect_url');
    	if ($url) {
    		$base = $data->get_option('wdfb_connect', 'login_redirect_base');
    		$base = ('admin_url' == $base) ? 'admin_url' : 'site_url';
    		$redirect_url = $base($url);
    	} else {
    		if (!defined('BP_VERSION') && $force_admin_redirect) {
    			// Forcing admin url redirection
    			$redirect_url = admin_url();
    		} else {
    			// Non-admin URL redirection, no specific settings
    
    			if (isset($_GET['redirect_to'])) {
    				// ... via GET parameter
    				$redirect_url = $_GET['redirect_to'];
    			} else {
    				// ... via heuristics and settings
    				global $post, $wp;
    				if (is_singular() && is_object($post) && isset($post->ID)) {
    					// Set to permalink for current item, if possible
    					$redirect_url = apply_filters('wdfb-login-redirect_url-item_url', get_permalink($post->ID));
    				}
    				$fallback_url = (defined('WDFB_EXACT_REDIRECT_URL_FALLBACK') && WDFB_EXACT_REDIRECT_URL_FALLBACK) ? site_url($wp->request) : home_url();
    				// Default to home URL otherwise
    				$redirect_url = $redirect_url ? $redirect_url : $fallback_url;
    			}
    		}
    	}
    
    	return apply_filters('wdfb-login-redirect_url', $redirect_url);
    }

    To this :

    /**
     * Helper function for getting the login redirect URL.
     */
    function wdfb_get_login_redirect ($force_admin_redirect=false) {
    	$redirect_url = false;
    	$data = Wdfb_OptionsRegistry::get_instance();
    	$url = $data->get_option('wdfb_connect', 'login_redirect_url');
    	if ($url) {
    		// HENRIK GREGERSEN HACK-->
    		if ( isset( $_REQUEST['redirect_to'] ) )
    			$redirect_url = $_REQUEST['redirect_to'];
    		else {
    			$base = $data->get_option('wdfb_connect', 'login_redirect_base');
    			$base = ('admin_url' == $base) ? 'admin_url' : 'site_url';
    			$redirect_url = $base($url);
    		}
    		// HENRIK GREGERSEN HACK<--
    	} else {
    		if (!defined('BP_VERSION') && $force_admin_redirect) {
    			// Forcing admin url redirection
    			$redirect_url = admin_url();
    		} else {
    			// Non-admin URL redirection, no specific settings
    
    			if (isset($_GET['redirect_to'])) {
    				// ... via GET parameter
    				$redirect_url = $_GET['redirect_to'];
    			} else {
    				// ... via heuristics and settings
    				global $post, $wp;
    				if (is_singular() && is_object($post) && isset($post->ID)) {
    					// Set to permalink for current item, if possible
    					$redirect_url = apply_filters('wdfb-login-redirect_url-item_url', get_permalink($post->ID));
    				}
    				$fallback_url = (defined('WDFB_EXACT_REDIRECT_URL_FALLBACK') && WDFB_EXACT_REDIRECT_URL_FALLBACK) ? site_url($wp->request) : home_url();
    				// Default to home URL otherwise
    				$redirect_url = $redirect_url ? $redirect_url : $fallback_url;
    			}
    		}
    	}
    
    	return apply_filters('wdfb-login-redirect_url', $redirect_url);
    }

    Then it works.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.