PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

redirecting index.php to wp-login.php?

s2Member Plugin. A Membership plugin for WordPress®.

redirecting index.php to wp-login.php?

Postby zerotosran » April 13th, 2011, 1:52 pm

i'd like to have my index.php to automatically reirect to wp-login.php. how can i make this possible?
User avatar
zerotosran
Registered User
Registered User
 
Posts: 7
Joined: April 13, 2011

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

Postby Cristián Lávaque » April 14th, 2011, 12:22 am

You mean have wp-login.php be the homepage of your website?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

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

Postby zerotosran » April 14th, 2011, 12:50 am

Yes.
By doing that. I can lock my website from unregistered users. But how can i?
User avatar
zerotosran
Registered User
Registered User
 
Posts: 7
Joined: April 13, 2011

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

Postby Cristián Lávaque » April 14th, 2011, 2:05 am

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
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

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

Postby drbyte » April 14th, 2011, 3:00 am

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
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

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

Postby zerotosran » April 14th, 2011, 12:08 pm

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 ?>
User avatar
zerotosran
Registered User
Registered User
 
Posts: 7
Joined: April 13, 2011

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

Postby drbyte » April 14th, 2011, 5:12 pm

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 } ?>
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

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

Postby Cristián Lávaque » April 15th, 2011, 1:59 am

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. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

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

Postby zerotosran » April 16th, 2011, 2:51 pm

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.
User avatar
zerotosran
Registered User
Registered User
 
Posts: 7
Joined: April 13, 2011

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

Postby zerotosran » April 21st, 2011, 1:38 pm

so, i've used alternative protection option because it was the solution that i was looking for. it doesn't work
User avatar
zerotosran
Registered User
Registered User
 
Posts: 7
Joined: April 13, 2011

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

Postby Cristián Lávaque » April 21st, 2011, 1:52 pm

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. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

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

Postby zerotosran » April 21st, 2011, 5:57 pm

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.
Last edited by zerotosran on April 21st, 2011, 9:49 pm, edited 1 time in total.
User avatar
zerotosran
Registered User
Registered User
 
Posts: 7
Joined: April 13, 2011

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

Postby Cristián Lávaque » April 21st, 2011, 7:27 pm

OK. Did you watch the videos I suggested?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

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

Postby zerotosran » April 21st, 2011, 9:48 pm

Cristián Lávaque wrote:OK. Did you watch the videos I suggested?


it worked!!! thank you.
User avatar
zerotosran
Registered User
Registered User
 
Posts: 7
Joined: April 13, 2011

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

Postby Cristián Lávaque » April 21st, 2011, 10:05 pm

Great. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 3 guests

cron