How to open hyperlinks in a new tab

This thread spoke about directly links embedded:

I’m referring to links using hyperlink button:

[Google Test](http://www.google.com)

Google Test

How do I get this to open in a new tab?

1 Like

Change your user preference for this and reload the page, then click on it?

4 Likes

Yep that works at the individual user, would that setting also work through the Admin interface for all users (default other external links in new tab) or would each user go and set that setting?

Hmm I think I see what happened, since I already had an account, changing the setting through the Admin interface didn’t make a difference. So I’m assuming that when a new user signs up s/he will automatically have that setting enabled, but changing this admin setting doesn’t reset existing users settings. Am I correct?

2 Likes

Yes, site default settings get applied at account creation time. Get your important ones set up early.

6 Likes

If you already have a tonne of users to update and have console access then you can run an SQL update against the database as below. Please create and download a backup first.

cd /var/discourse/
./launcher enter app
su discourse
psql
UPDATE USER_OPTIONS 
SET EXTERNAL_LINKS_IN_NEW_TAB = 't'
WHERE  USER_ID <> -1 
AND EXTERNAL_LINKS_IN_NEW_TAB = 'f';
\q
exit
exit

Also be aware that this will affect users who may have actually chosen not to use external links. If you wanted to see who it would affect before running it then I would install the Data Explorer plugin and use the following query:

SELECT u.ID        "User ID" 
       ,u.USERNAME "Username" 
       ,u.NAME     "Name" 
       ,CASE uo.EXTERNAL_LINKS_IN_NEW_TAB 
          WHEN 't' THEN 'True' 
          WHEN 'f' THEN 'False' 
          ELSE 'Not set' 
        END        "External links?"
FROM   USERS u 
       LEFT OUTER JOIN USER_OPTIONS uo 
                    ON u.ID = uo.USER_ID 
WHERE  uo.EXTERNAL_LINKS_IN_NEW_TAB = 'f' 
   AND u.ID <> -1
6 Likes