I have a plugin that allow my users in multisite to generate simple urls like http://example.com/user/?my_url=2DD0B8183 but i want to include the https instead http ...

echo '<div>';
    echo '<div><input type="text" class="url" value="' .get_option('home'). '/?my_url=' . $download["code"] . '" onclick="this.select();" /></div>';

I tried

echo '<div><input type="text" class="url" value="https://' .get_blogaddress_by_id( $user_info->primary_blog ) . '?my_url=' . $download["code"] . '" onclick="this.select();" /></div>';

but i get https://http://example.com/user/?my_url=C4785825B

I have already forced ssl/https for entire my network via .htaccess

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

1 Answer 1


Instead of get_option, use home_url which will determine ...

the appropriate protocol, "https" if is_ssl() and "http" otherwise. If the $scheme argument is "http" or "https" the is_ssl() check is overridden.

In fact, network_home_url would be more appropriate since you are talking about Multisite.

Those should return the same value that you are trying the access in your code-- the home option key-- but with the appropriate protocol.

This may not be the URL you want though. You may want site_url or the multisite equivalent, network_site_url.

  • @Ghinnersmee : yep. I used a function that returns the same address as get_option('home'), which you were trying to use, but with the appropriate protocol. What you needed was a different address altogether. I will update the answer for future visitors.
    – s_ha_dum
    Commented Jun 25, 2013 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.