# כיצד למנף את ההגדרה "פתח את כל הקישורים החיצוניים בלשונית חדשה" בהתאמות אישיות של אתר

**URL:** https://meta.discourse.org/t/how-to-leverage-the-open-all-external-links-in-a-new-tab-setting-in-site-customizations/258174
**Category:** Development
**Created:** [15 במרץ,‏ 2023,‏ 3:08am UTC](https://meta.discourse.org/t/how-to-leverage-the-open-all-external-links-in-a-new-tab-setting-in-site-customizations/258174 "2023-03-15T03:08:51Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [15 במרץ,‏ 2023,‏ 10:08pm UTC](https://meta.discourse.org/t/how-to-leverage-the-open-all-external-links-in-a-new-tab-setting-in-site-customizations/258174/8 "2023-03-15T22:08:11Z")

</div>

Ah right, I overlooked the “user” part 😅 sorry

It’s not much different to use the user setting, you’d just have to change the first two constants to reference the user:

```js
// set up the user and target variable:
const user = api.getCurrentUser()
const target = user?.user_option?.external_links_in_new_tab ? "_blank" : ""

```

and then everything else would be the same.

If this were to work more like core, we’d check if the user exists, and if they don’t, fall back to the site setting:

```js
// set up the user, siteSettings, and target variable:
const user = api.getCurrentUser()
const siteSettings = api.container.lookup('site-settings:main');
let target = siteSettings.default_other_external_links_in_new_tab ? "_blank" : ""; 

if (user) { // if the user exists, set the target based on the user option
 target = user.user_option?.external_links_in_new_tab ? "_blank" : ""
} 

// modify the if statement where the link is created to use the target variable: 
if (userFields && userFields[userFieldId]) {
  const url = "http://myawesomewebsite.com/user/" + userFields[userFieldId];
  const link = `<a href="${url}" target="${target}">${url}</a>`;
  return Ember.Object.create({ link, name: externalUserIdField.get('name') });
} else {
  return null;
}

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-leverage-the-open-all-external-links-in-a-new-tab-setting-in-site-customizations/258174)._
