Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter chazzo

    (@chazzo)

    Working perfectly. You’re a star. This is a massive kludge, but for anyone who could use it:

    
    function my_auto_login() {
        if ( ! is_user_logged_in() ) {
            $creds = array(
                'user_login'    => 'Subscriber',
                'user_password' => 'xxxxxxxxxxxxxxxxx',
                'remember'      => false
            );
            $user = wp_signon( $creds, is_ssl() );
            if ( is_wp_error( $user ) ) {
                echo $user->get_error_message();
            }
        }
    }
    
    add_action( 'restrict_site_access_ip_match', 'my_auto_login' );
    
    • This reply was modified 4 years, 1 month ago by chazzo.
    Thread Starter chazzo

    (@chazzo)

    Excellent, thank you. I’ll try that.

    Thread Starter chazzo

    (@chazzo)

    @dinhtungdu Many thanks for listening. This is an extremely useful plugin and I can see you spend a good deal of time supporting it. It’s appreciated!

    So … I have a restricted site that users access either from approved IP addresses or by logging in. For IP control, RSA is working well. For the logged-in users, I want to assign them various profiles and use those profiles to control which pages they can see. For that, I have the Simple Restrict Content plugin installed.

    The problem, of course, is that the content restriction plugin blocks anyone who is not logged in, including anyone visiting from an IP address approved by RSA. So I thought I’d write a function to detect when that happens, and log these visitors in automatically with a generic profile. I’ve tested wp_signon() for the auto-login and it seems to work.

    As I see it, I can’t use is_user_logged_in() because that will simply log everyone in automatically, which is not what we want. Instead, I really do want to detect visitors who’ve passed RSA’s IP check.

    I am not a developer and I know this is all a big fudge. Nevertheless, suggestions welcome.

    • This reply was modified 4 years, 1 month ago by chazzo.
    Thread Starter chazzo

    (@chazzo)

    Apologies, all. I think this was caused by a misconfiguration of another plugin, “Restrict User Access”. If some kind mod would care to delete this thread, it would be a service to other viewers.

    Thread Starter chazzo

    (@chazzo)

    RSA is currently turned off (“Allow search engines to index this site”). Following the link above, you should therefore see a short page with a prominent heading “MobileTex”. If you see “Please log in” instead, that’s the unwanted redirect.

Viewing 5 replies - 1 through 5 (of 5 total)