# Problem redirecting to forum after login when using MemberMouse

**URL:** https://meta.discourse.org/t/problem-redirecting-to-forum-after-login-when-using-membermouse/77871
**Category:** WordPress
**Created:** [1월 12, 2018, 7:22오후 UTC](https://meta.discourse.org/t/problem-redirecting-to-forum-after-login-when-using-membermouse/77871 "2018-01-12T19:22:17Z")
**Posts on this page:** 1
**Showing post:** 14

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [5월 30, 2018, 2:50오전 UTC](https://meta.discourse.org/t/problem-redirecting-to-forum-after-login-when-using-membermouse/77871/14 "2018-05-30T02:50:29Z")

</div>

Thanks for doing this! I installed the Membermouse plugin in my development environment today. Getting the redirect back to Discourse is harder than I expected. I don’t think there’s any reason to change the way you are doing it, but here’s an alternate approach. It at least shows how the plugin expects things to work. Generally, it should be possible to do this by hooking into the WordPress `login_redirect` filter and getting the Discourse `redirect_to` parameter from that filter’s `$request` parameter. This can’t be done with Membermouse though.

This function depends on being able to get the `HTTP_REFERER` with `wp_get_referer`. The referer may not always be available. If it isn’t, the user will be redirected to the default Membermouse redirect. I have only tested this in my development environment.

```php
add_filter( 'mm_login_redirect', 'wpdc_login_redirect_override' );
function wpdc_login_redirect_override() {
    $referer = wp_get_referer();
    if ( $referer ) {
	    $query_params = [];
	    parse_str( parse_url( $referer, PHP_URL_QUERY ), $query_params );
	    if ( isset( $query_params['redirect_to'] ) ) {

		    return home_url( $query_params['redirect_to'] );
	    }
    }

	return '';
}

```

---

_[View the full topic](https://meta.discourse.org/t/problem-redirecting-to-forum-after-login-when-using-membermouse/77871)._
