Page 1 of 1

redirecting index.php to wp-login.php?

PostPosted: April 13th, 2011, 1:52 pm
by zerotosran
i'd like to have my index.php to automatically reirect to wp-login.php. how can i make this possible?

Re: redirecting index.php to wp-login.php?

PostPosted: April 14th, 2011, 12:22 am
by Cristián Lávaque
You mean have wp-login.php be the homepage of your website?

Re: redirecting index.php to wp-login.php?

PostPosted: April 14th, 2011, 12:50 am
by zerotosran
Yes.
By doing that. I can lock my website from unregistered users. But how can i?

Re: redirecting index.php to wp-login.php?

PostPosted: April 14th, 2011, 2:05 am
by Cristián Lávaque
You could edit the template file for the homepage and use a conditional to check if the person is logged in before showing the posts, and redirect to wp-login.php if not.

WP Admin -> s2Member -> API / Scripting

Re: redirecting index.php to wp-login.php?

PostPosted: April 14th, 2011, 3:00 am
by drbyte
Are using the Pro or the free version of S2m?

The free version

Options 1
Using .htaccess

Code: Select all
Options +FollowSymLinks
RewriteEngine on
# index.php to /wp-login.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]


Option 2

Create a new page..call it login

drop this into the HTML text editor:

Code: Select all
<form name="loginform" id="loginform" action="http://www.site.com/wp-login.php" method="post">
<p>
<label>Username *<br />
<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
</p>
<p>
<label>Password *<br />
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
</p>
<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="100" />
<input type="hidden" name="redirect_to" value="http://www.site.com/wp-admin/" />
<input type="hidden" name="testcookie" value="1" />
</p>
</form>



Change the site.com to yours
Save the page

Go to wp-admin ----settings-----reading
Front page displays

Your latest posts
or
A static page (select below)

Choose the second option and from the drop down menu choose the page you just created

save..make sure you are log out and refresh your page...use another browser ..it makes it easier to see the changes without log in and log out

Now you need to protect your Categories/pages/posts ....Read the s2member general options instructions


Option 3

Use meta data

inset this to the meta data in your theme usually in the header.php

<meta http-equiv="refresh" content="10; url=http://example.com/wp-login">

In all cases you need to protect your Categories/Pages/and Posts with S2m so no matter what they do they will get either the log in page or the membership page

There are other ways to do so...try the above first and let me know

Sam

Re: redirecting index.php to wp-login.php?

PostPosted: April 14th, 2011, 12:08 pm
by zerotosran
Cristián Lávaque wrote:You could edit the template file for the homepage and use a conditional to check if the person is logged in before showing the posts, and redirect to wp-login.php if not.

WP Admin -> s2Member -> API / Scripting


i am new to coding world, sorry about the frequent questions.

so let say if my template indexpage code goes like

Code: Select all
<?php get_header(); ?>
<?php dynamic_sidebar
(1); ?>
            <?php if(get_option("ocmx_home_page_layout") == "widget") :
                if (
function_exists('dynamic_sidebar') && is_active_sidebar(2)) : ?> 
                <div id="widget-block" class="clearfix">
                    <ul class="widget-list">
                        <?php dynamic_sidebar(2); ?>
                    </ul>
                </div>
                <?php endif; 
            else : 
?>
      <ul class="double-cloumn clearfix">
          <li id="left-column">
                <ul class="blog-main-post-container">
                    <?php if (have_posts()) :
                        global 
$show_author;
                        
$show_author 1;
                        while (
have_posts()) :    the_post(); setup_postdata($post);
                            include(
TEMPLATEPATH."/functions/fetch-list.php");
                        endwhile;
                    else :
                        
ocmx_no_posts();
                    endif; 
?>
                </ul>
                <?php motionpic_pagination("clearfix""pagination clearfix"); ?>
        </li>
        <?php get_sidebar(); ?>
    </ul>
    <?php endif; ?>
<?php get_footer
(); ?>


where should i put these in?
Code: Select all
<?php if(is_user_logged_in()){ ?>
    Content for anyone that is logged in, regardless of their Membership Level.
<?php } else { ?>
    Some public content.
<?php ?>

Re: redirecting index.php to wp-login.php?

PostPosted: April 14th, 2011, 5:12 pm
by drbyte
This will only show login form to none members including the header and footer....once they are logged in then it will show everything including your side bars.

Code: Select all
<?php if(is_user_logged_in()){ ?>
<?php get_header(); ?>
    <?php dynamic_sidebar(1); ?>
                <?php if(get_option("ocmx_home_page_layout") == "widget") :
                    if (function_exists('dynamic_sidebar') && is_active_sidebar(2)) : ?>
                    <div id="widget-block" class="clearfix">
                        <ul class="widget-list">
                            <?php dynamic_sidebar(2); ?>
                        </ul>
                    </div>
                    <?php endif;
                else : ?>
          <ul class="double-cloumn clearfix">
              <li id="left-column">
                    <ul class="blog-main-post-container">
                        <?php if (have_posts()) :
                            global $show_author;
                            $show_author = 1;
                            while (have_posts()) :    the_post(); setup_postdata($post);
                                include(TEMPLATEPATH."/functions/fetch-list.php");
                            endwhile;
                        else :
                            ocmx_no_posts();
                        endif; ?>
                    </ul>
                    <?php motionpic_pagination("clearfix", "pagination clearfix"); ?>
            </li>
            <?php get_sidebar(); ?>
        </ul>
        <?php endif; ?>
<?php get_footer(); ?>
    <?php } else { ?>
        <?php get_header(); ?>
<form name="loginform" id="loginform" action="http://www.site.com/wp-login.php" method="post">
<p>
<label>Username *<br />
<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
</p>
<p>
<label>Password *<br />
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
</p>
<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="100" />
<input type="hidden" name="redirect_to" value="http://www.site.com/wp-admin/" />
<input type="hidden" name="testcookie" value="1" />
</p>
</form>
<?php get_footer(); ?>
    <?php } ?>

Re: redirecting index.php to wp-login.php?

PostPosted: April 15th, 2011, 1:59 am
by Cristián Lávaque
zerotosran wrote:where should i put these in?


This is the part of your template that shows the posts:

Code: Select all
<ul class="blog-main-post-container">
    <?php if (have_posts()) :
        global $show_author;
        $show_author = 1;
        while (have_posts()) :    the_post(); setup_postdata($post);
            include(TEMPLATEPATH."/functions/fetch-list.php");
        endwhile;
    else :
        ocmx_no_posts();
    endif; ?>
</ul>


So you wrap that with the condition that the person is logged in.

Code: Select all
<?php if (user_is_logged_in()) { ?>

    <ul class="blog-main-post-container">
        <?php if (have_posts()) :
            global $show_author;
            $show_author = 1;
            while (have_posts()) :    the_post(); setup_postdata($post);
                include(TEMPLATEPATH."/functions/fetch-list.php");
            endwhile;
        else :
            ocmx_no_posts();
        endif; ?>
    </ul>

<?php } else { ?>

    Here goes the message you want to give to those who aren't logged in.

<?php } ?>


I hope that helps you. :)

Re: redirecting index.php to wp-login.php?

PostPosted: April 16th, 2011, 2:51 pm
by zerotosran
drbyte wrote:This will only show login form to none members including the header and footer....once they are logged in then it will show everything including your side bars.

Code: Select all
<?php if(is_user_logged_in()){ ?>
<?php get_header(); ?>
    <?php dynamic_sidebar(1); ?>
                <?php if(get_option("ocmx_home_page_layout") == "widget") :
                    if (function_exists('dynamic_sidebar') && is_active_sidebar(2)) : ?>
                    <div id="widget-block" class="clearfix">
                        <ul class="widget-list">
                            <?php dynamic_sidebar(2); ?>
                        </ul>
                    </div>
                    <?php endif;
                else : ?>
          <ul class="double-cloumn clearfix">
              <li id="left-column">
                    <ul class="blog-main-post-container">
                        <?php if (have_posts()) :
                            global $show_author;
                            $show_author = 1;
                            while (have_posts()) :    the_post(); setup_postdata($post);
                                include(TEMPLATEPATH."/functions/fetch-list.php");
                            endwhile;
                        else :
                            ocmx_no_posts();
                        endif; ?>
                    </ul>
                    <?php motionpic_pagination("clearfix", "pagination clearfix"); ?>
            </li>
            <?php get_sidebar(); ?>
        </ul>
        <?php endif; ?>
<?php get_footer(); ?>
    <?php } else { ?>
        <?php get_header(); ?>
<form name="loginform" id="loginform" action="http://www.site.com/wp-login.php" method="post">
<p>
<label>Username *<br />
<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
</p>
<p>
<label>Password *<br />
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
</p>
<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="100" />
<input type="hidden" name="redirect_to" value="http://www.site.com/wp-admin/" />
<input type="hidden" name="testcookie" value="1" />
</p>
</form>
<?php get_footer(); ?>
    <?php } ?>


THANKS!! i think i am heading somewhere with your code, but pages of files or contents are still accessible by typing in the pageID number. all my page that are accessable by doing so, have custom template and it looks like this
Code: Select all
<?php /* Template Name: Widgetized Page */
get_header();
$widget_title = $post->post_title;
dynamic_sidebar($widget_title." Slider Widget");
if (function_exists('dynamic_sidebar') && is_active_sidebar($widget_title." 3 Column")) : ?>
    <div id="widget-block" class="clearfix">
        <ul class="widget-list">
            <?php dynamic_sidebar($widget_title." 3 Column"); ?>
        </ul>
    </div>
    <?php endif;
get_footer(); ?>

how can i block the contents?
i tried to fiddle with [Specific Post/Page Access Restrictions ( optional )] still does not block or put restrictions for non-login members.

Re: redirecting index.php to wp-login.php?

PostPosted: April 21st, 2011, 1:38 pm
by zerotosran
so, i've used alternative protection option because it was the solution that i was looking for. it doesn't work

Re: redirecting index.php to wp-login.php?

PostPosted: April 21st, 2011, 1:52 pm
by Cristián Lávaque
zerotosran wrote:so, i've used alternative protection option because it was the solution that i was looking for. it doesn't work


Could you explain what you did, what happens, and what you expected?

Also, I suggest you watch these:
http://www.s2member.com/general-options-overview-video/
http://www.s2member.com/content-restric ... ble-video/

I hope that helps. :)

Re: redirecting index.php to wp-login.php?

PostPosted: April 21st, 2011, 5:57 pm
by zerotosran
Cristián Lávaque wrote:
zerotosran wrote:so, i've used alternative protection option because it was the solution that i was looking for. it doesn't work


Could you explain what you did, what happens, and what you expected?

Also, I suggest you watch these:
http://www.s2member.com/general-options-overview-video/
http://www.s2member.com/content-restric ... ble-video/

I hope that helps. :)



see my website for an example. . the index pages shows by the widgeted page. even with alternative protection option set to "YES"(the last one) it still shows the website.

Re: redirecting index.php to wp-login.php?

PostPosted: April 21st, 2011, 7:27 pm
by Cristián Lávaque
OK. Did you watch the videos I suggested?

Re: redirecting index.php to wp-login.php?

PostPosted: April 21st, 2011, 9:48 pm
by zerotosran
Cristián Lávaque wrote:OK. Did you watch the videos I suggested?


it worked!!! thank you.

Re: redirecting index.php to wp-login.php?

PostPosted: April 21st, 2011, 10:05 pm
by Cristián Lávaque
Great. :)