Title: Output user_url without  http://
Last modified: August 24, 2016

---

# Output user_url without http://

 *  [Luke](https://wordpress.org/support/users/danceyrselfclean_admin/)
 * (@danceyrselfclean_admin)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/output-user_url-without-http/)
 * Hi I am using user_url on my site to display the website a user has entered on
   their profile. However I need the output to display as whatever they enter in
   the field, instead of it adding http:// every time.
 * Any assistance would be appreciated.

Viewing 1 replies (of 1 total)

 *  [Aubrey Portwood](https://wordpress.org/support/users/aubreypwd/)
 * (@aubreypwd)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/output-user_url-without-http/#post-6115830)
 * I’m assuming WordPress is applying `esc_url()` to that value to ensure a valid
   URL. A domain would not qualify as a proper URL and therefore `esc_url()` adds`
   http://` to it to ensure it’s a URL.
 * See [https://codex.wordpress.org/Data_Validation](https://codex.wordpress.org/Data_Validation)
   for more on why they force `http://`.
 * **There are a couple things you can do.**
 * One is replace `http://` in the string with nothing on the front end:
 *     ```
       $replacements = array(
       	'http://' => '',
       	'https://' => '',
       );
   
       echo strtr( $user_url, $replacements );
       ```
   
 * That, of course, would honor WordPress’s addition to `http://` in the database,
   but replace it on the front-end.
 * If you want the DB stored value to not have `http://` you’ll have to do something
   like this:
 *     ```
       function dont_http( $raw_url ) {
       	$replacements = array(
       		'http://' => '',
       		'https://' => '',
       	);
   
       	return strtr( $raw_url, $replacements );
       }
   
       add_filter( 'pre_user_url', 'dont_http' );
       ```
   
 * See [https://developer.wordpress.org/reference/hooks/pre_user_url/](https://developer.wordpress.org/reference/hooks/pre_user_url/)
   for more.
 * The other option is not use `$user->user_url`. You could create a new User Meta
   field called `user_domain` where the `http://` won’t be added automatically, 
   it will be whatever you store in there.
 * [http://wpengineer.com/2173/custom-fields-wordpress-user-profile/](http://wpengineer.com/2173/custom-fields-wordpress-user-profile/)
   has a pretty simple guide on adding custom meta for users.

Viewing 1 replies (of 1 total)

The topic ‘Output user_url without http://’ is closed to new replies.

## Tags

 * [user_url](https://wordpress.org/support/topic-tag/user_url/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Aubrey Portwood](https://wordpress.org/support/users/aubreypwd/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/output-user_url-without-http/#post-6115830)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
