# 2 questions about WP Discourse

**URL:** https://meta.discourse.org/t/2-questions-about-wp-discourse/75866
**Category:** WordPress
**Created:** [December 12, 2017, 12:11pm UTC](https://meta.discourse.org/t/2-questions-about-wp-discourse/75866 "2017-12-12T12:11:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [December 12, 2017, 12:11pm UTC](https://meta.discourse.org/t/2-questions-about-wp-discourse/75866/1 "2017-12-12T12:11:01Z")

</div>

Is there any way to make an SSO link redirect to an URL with an anchor? I’m using Wordpress as a SSO client.

`http://example.com/?discourse_sso=1&redirect_to=http://example.com/welcome#anchor`  
will redirect to  
`http://example.com/welcome#anchor?sso=fddsgsfzqefefsdfs` or something like that… So that’s not working.

Other question: is it possible to automatically log out from Wordpress when we log out from Discourse (still using Wordpress as an SSO client), the same way as Discourse disconnects automatically when logging out from Wordpress when using Wordpress as an SSO provider?

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [December 12, 2017, 2:33pm UTC](https://meta.discourse.org/t/2-questions-about-wp-discourse/75866/2 "2017-12-12T14:33:17Z")

</div>

> [@hanks](#):
>
> SSO link redirect to an URL with an anchor?

What are You trying to achieve? there may be a different way to implement that.

> [@hanks](#):
>
> is it possible to automatically log out from Wordpress when we log out from Discourse

There is a forum thread about it [here](https://meta.discourse.org/t/wp-and-discourse-not-in-sync-using-sso/47564)

The solution is:

> [@WP and Discourse not in sync using SSO](https://meta.discourse.org/t/wp-and-discourse-not-in-sync-using-sso/47564/2):
>
> If you add the path `http://your-blog.com/?request=logout` to the ‘logout redirect’ setting in Discourse logging out from Discourse will log you out from WordPress. I’ll add that to the documentation.

---

<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: [December 12, 2017, 3:43pm UTC](https://meta.discourse.org/t/2-questions-about-wp-discourse/75866/3 "2017-12-12T15:43:19Z")

</div>

> [@hanks](#):
>
> Is there any way to make an SSO link redirect to an URL with an anchor?

Try URL encoding the redirect parameter:

`http://example.com/welcome#anchor` becomes `http%3A%2F%2Fexample.com%2Fwelcome%23anchor`

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [December 12, 2017, 11:17pm UTC](https://meta.discourse.org/t/2-questions-about-wp-discourse/75866/4 "2017-12-12T23:17:40Z")

</div>

Hello and thanks you for your replies.

> [@itsbhanusharma](#):
>
> What are You trying to achieve? there may be a different way to implement that.

When a user is on a Wordpress post page, I’ve added a button “log in to post a comment” to the bottom of the comments. If the user clicks this button, I’d like them to be redirected at the bottom of the comments (via an anchor) after they successfully log in.

Thank you for the logout reply!

> [@simon](#):
>
> Try URL encoding the redirect parameter:

Unfortunately, I’ve already tried it with no success…

Another question: is it possible to automatically log in Wordpress when logging in Discourse?

---

<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: [December 13, 2017, 5:26pm UTC](https://meta.discourse.org/t/2-questions-about-wp-discourse/75866/5 "2017-12-13T17:26:58Z")

</div>

> [@hanks](#):
>
> Is there any way to make an SSO link redirect to an URL with an anchor? I’m using Wordpress as a SSO client.

In my development environment, this works if I do not urlencode the `redirect_to` parameter. Whether or not this works may depend on your WordPress site’s server configuration.

> [@hanks](#):
>
> is it possible to automatically log in Wordpress when logging in Discourse?

It’s theoretically possible, but would require a Discourse plugin. I’m not sure that it would be worth the trouble. Adding a WordPress SSO login link to your forum should take care of most cases.

If you want to automatically create WordPress users when they are created on Discourse, a Discourse plugin could be written that posts to the WordPress REST API users/ route.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [December 13, 2017, 6:05pm UTC](https://meta.discourse.org/t/2-questions-about-wp-discourse/75866/6 "2017-12-13T18:05:44Z")

</div>

After a few tests it appears that redirections with an anchor from WP works only if the user is already logged on Discourse.

Works in this case : WP not logged in → Discourse already logged in → logs user to WP  
And not in this one : WP not logged in → Discourse not logged in → user logs in Discourse → logs user to WP

But that doesn’t matter much after all.

Thank you for your replies. 🙂
