Community Support Forums — WordPress® ( Users Helping Users ) — 2011-12-05T06:17:10-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=15918 2011-12-05T06:17:10-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=54581#p54581 <![CDATA[Re: Automatic login for a specific ip address]]>
All in One SEO Pack
Contact Form 7
Google Analytics for Wordpress
Relevanssi
Sidebar Login
Widget Logic
Wordpress Importer
WP Show IDs

When I get a chance I will go through and start from scratch adding the plugins etc. Ill report back if I find a culprit/can get it working.

Perhaps one day we will see this option available natively in s2 :) ?

Statistics: Posted by tasitasi — December 5th, 2011, 6:17 am


]]>
2011-12-01T01:20:22-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=54277#p54277 <![CDATA[Re: Automatic login for a specific ip address]]>
Do you have an error log from the server or PHP?

Statistics: Posted by Cristián Lávaque — December 1st, 2011, 1:20 am


]]>
2011-11-28T17:07:32-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=54103#p54103 <![CDATA[Re: Automatic login for a specific ip address]]>
I have tried so many different things and have not once had it log me in automatically. Is driving me crazy, but for now I have a workaround, which unfortunately involves duplicating the entire site somewhere else and redirecting certain ip addresses to that. Yuck!

Statistics: Posted by tasitasi — November 28th, 2011, 5:07 pm


]]>
2011-11-28T09:11:48-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=54075#p54075 <![CDATA[Re: Automatic login for a specific ip address]]> WP Admin -> s2Member -> General Options -> Localhost WAMP/MAMP Developers?

Statistics: Posted by Eduan — November 28th, 2011, 9:11 am


]]>
2011-11-28T04:06:18-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=54063#p54063 <![CDATA[Re: Automatic login for a specific ip address]]>
I tried it live on the actual site and for anyone with any other IP it just shows blank screens for each page.
For me (im using my ip address in the script) I can see the unrestricted pages fine, any s2member protected page is blank, and the page of the page ID I put in the page_id var redirects to "http://www.nzgsd.co.nz/wp-login.php?redirect_to=/", but its a blank page where without the script that link shows the login page. It does not log me in either.

The php looks all good to me - not that I would know any different, I am just stumped by this. Any other suggestions I would really appreciate! :)

Statistics: Posted by tasitasi — November 28th, 2011, 4:06 am


]]>
2011-11-28T02:26:24-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=54060#p54060 <![CDATA[Re: Automatic login for a specific ip address]]>
Code:
    <?php
    function auto_login_for_specific_ip ()
        {
            //Change this to the correct page id for your Membership Options Page
            $page_id = 10;
            //Customize this to the static IP you mentioned earlier
            $user_ip = '127.0.0.1';
            //Customize this to the correct user login for the users
            $user_login = 'demo';
            //Customize this to the correct password.
            $user_pass = 'demo';
            //If the user is logged in, or if the IP doesn't match, exit the script
            if (is_user_logged_in () || $_SERVER['REMOTE_ADDR'] != $user_ip)
                exit ();
            //To prevent errors
            wp_reset_query();
            //Check to see if page is correct.
            if (is_page ($page_id))
                {
                    //Should be set if the user is trying to access a protected page.
                    $redirect = $_GET['s2member_seeking'];
                    //To find the correct page/post id's
                        $redirect = str_replace (array('page-', 'post-'), array('?page_id=', '?p='), $redirect);
                    //Send Login Details
                    echo '<form name="autologin" action="' . get_option ('siteurl') . '/wp-login.php?redirect_to=/' . $redirect . '" method="post"><input type="hidden" name="log" value="' . $user_login . '"/><input type="hidden" name="pwd" value="' . $user_pass . '"/></form>';
                    echo '<script type="text/javascript">document.autologin.submit();</script>';
                }
        }
    add_action ('wp_head', 'auto_login_for_specific_ip');
    ?>

Statistics: Posted by Bruce C — November 28th, 2011, 2:26 am


]]>
2011-11-28T01:22:58-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=54051#p54051 <![CDATA[Re: Automatic login for a specific ip address]]>
Is there anything wrong with this?:

<form id="autologin" action="http://localhost/nzgsd/wp-login.php?redirect_to=/" method="post"><input type="hidden" name="log" value="admin"/><input type="hidden" name="pwd" value="password"/></form><script type="text/javascript"> function javaautolog () { var frm = document.getElementById("autologin"); frm.submit(); } window.onload = myfunc;</script>

Im not a php expert by any means. But it appears it either does nothing, or takes me to a blank page with the header cut off when this script come in.

Perhaps there is another option?

Statistics: Posted by tasitasi — November 28th, 2011, 1:22 am


]]>
2011-11-17T05:36:33-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=53287#p53287 <![CDATA[Re: Automatic login for a specific ip address]]>
So i tried this but it does not work for me. I created the folder mu-plugins, put the code in s2hacks.php and wordpress picked it up as a must use plugin. First I tried it locally on my wampserver copy of the site and it caused all pages to not load. The html source ends with <meta name="generator" content="WordPress 3.2.1" />

I then tried it on my live site and it did the same thing but only for the page I want it to log in to. All other pages load fine.

I also tried changing the page id to an unrestricted page, and that unrestricted page loads fine, but does not log me in. Again with this none of the protected pages load however. They also end <meta name="generator" content="WordPress 3.2.1" />

Maybe this info can shed some light on something I am doing wrong or something up with the code?

Could another option be to create a link to a dummy page that runs some of this auto login code, but just for anyone using the link? I would really appreciate any info to get this going :)

Thanks

Statistics: Posted by tasitasi — November 17th, 2011, 5:36 am


]]>
2011-11-16T17:13:46-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=53251#p53251 <![CDATA[Re: Automatic login for a specific ip address]]>

Statistics: Posted by tasitasi — November 16th, 2011, 5:13 pm


]]>
2011-11-16T13:35:06-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=53218#p53218 <![CDATA[Re: Automatic login for a specific ip address]]>

Statistics: Posted by Eduan — November 16th, 2011, 1:35 pm


]]>
2011-11-16T13:29:04-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=53216#p53216 <![CDATA[Re: Automatic login for a specific ip address]]>
What you can do is create a hook in 'wp-head'/the <head> part of WordPress when a user is viewing a page. Then you can check if the page is your membership options page, using the is_page() conditional. You'll need the page Id. I recommend getting WP Show ID's to do this.

Here's a code snippet that'll do what you need. Keep in mind that you need to update the value of the variables I set:

Code:
<?php
function auto_login_for_specific_ip 
()
    {
        //Change this to the correct page id for your Membership Options Page
        $page_id = 10;
        //Customize this to the static IP you mentioned earlier
        $user_ip = '127.0.0.1';
        //Customize this to the correct user login for the users
        $user_login = 'demo';
        //Customize this to the correct password.
        $user_pass = 'demo';
        //If the user is logged in, or if the IP doesn't match, exit the script
        if (is_user_logged_in () || $_SERVER['REMOTE_ADDR'] != $user_ip)
            exit ();
        //To prevent errors
        wp_reset_query();
        //Check to see if page is correct.
        if (is_page ($page_id))
            {
                //Should be set if the user is trying to access a protected page.
                $redirect = $_GET['s2member_seeking'];
                //To find the correct page/post id's
                    $redirect = str_replace (array('page-', 'post-'), array('?page_id=', '?p='), $redirect);
                //Send Login Details
                echo '<form id="autologin" action="' . get_option ('siteurl') . '/wp-login.php?redirect_to=/' . $redirect . '" method="post"><input type="hidden" name="log" value="' . $user_login . '"/><input type="hidden" name="pwd" value="' . $user_pass . '"/></form>';
                echo '<script type="text/javascript"> function javaautolog () { var frm = document.getElementById("autologin"); frm.submit(); } window.onload = myfunc;</script>';
            }
    }
add_action ('wp_head', 'auto_login_for_specific_ip');
?>


Put this in your s2hacks.php file ( if you don't have one, make one; under wp-content\mu-plugins\s2hacks.php )

Hope that helps!

Statistics: Posted by Bruce C — November 16th, 2011, 1:29 pm


]]>
2011-11-16T08:21:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=53178#p53178 <![CDATA[Re: Automatic login for a specific ip address]]> Mean while you can check under WP Admin -> s2Member -> Restriction Options -> Unique IP Access Restriction.

Hope this helps. :)

Statistics: Posted by Eduan — November 16th, 2011, 8:21 am


]]>
2011-11-16T04:40:50-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15918&p=53171#p53171 <![CDATA[Automatic login for a specific ip address]]>
I have a question about the s2member plugin. I have a large organisation looking to access my blog. All traffic from that organisation has the same static ip address, but its multiple computers/users within that organisation.

Can s2member automatically login a user from a specific ip address. For example if someone in that organisation is trying to access an s2member protected page, can s2member check the ip address, and if the ip address is "allowed" access to that page, log them in automatically?

What I am trying to avoid is many users from the same organisation having to continually log in. Ideally users from that organisation/ip address would see the site as if it was free.

Any info would be fantastic.

Thanks

Chris

Statistics: Posted by tasitasi — November 16th, 2011, 4:40 am


]]>