WordPress.org

Ready to get started?Download WordPress

Forums

WordPress HTTPS (SSL)
[resolved] Force SSL for users (6 posts)

  1. Christopher Holloway
    Member
    Posted 2 years ago #

    I want to be able for when users log in to my site that they stay on the secure side throughout the whole time they are logged in and when they log out they are taken back to a non secure side just as the admin area is done in this plugin??

    http://wordpress.org/extend/plugins/wordpress-https/

  2. Mvied
    Member
    Plugin Author

    Posted 2 years ago #

    So you want to secure all links for logged in users?

    You could do that pretty easily by adding this to your theme's functions.php:

    function logged_in_force_ssl( $force_ssl, $post_id ) {
        if ( is_user_logged_in() ) {
            $force_ssl = true;
        }
        return $force_ssl;
    }
    add_filter('force_ssl', 'logged_in_force_ssl', 10, 2);

    It may not work perfectly. Let me know.

  3. Christopher Holloway
    Member
    Posted 2 years ago #

    thanks very much. this works great. but i am wondering, when logged out, it doesn't go back to the non secure version of my site. is there a way to force it to be non secure http when not logged in?

  4. Mvied
    Member
    Plugin Author

    Posted 2 years ago #

    Same code, add an else statement.

    function logged_in_force_ssl( $force_ssl, $post_id ) {
        if ( is_user_logged_in() ) {
            $force_ssl = true;
        } else {
            $force_ssl = false;
        }
        return $force_ssl;
    }
    add_filter('force_ssl', 'logged_in_force_ssl', 10, 2);
  5. G
    Member
    Posted 1 year ago #

    @Mvied
    I tried the above code, but had problem - white screen of death...
    So too trying your WordPress https plugin.

    I want ssl active for logged in users, http for guests.

    WordPress 3.5 (Network), Buddypress 1.6.2, WP-Super-cache 1.2

    Any ideas?

  6. G
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic