If not logged in, show login page content
authorLaury GvR <laury@gaslightmedia.com>
Mon, 5 Mar 2018 22:56:23 +0000 (17:56 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Mon, 5 Mar 2018 22:56:23 +0000 (17:56 -0500)
It was so that when one is on the members only page, the content
of that page would show in addition to the login form. This was
requested to be changed so that the members only login page text is
separate from the members only page text.

Code has also been added to try handling redirection; currently
when someone logs in on the front-end, the Contacts plugin forces
them to be redirected to the members only page, even if a different
url is supplied to the form. If that can be disabled, this code
would make it so one is only navigated to the Members Only page if
attempting to log in from the Members Only Login page, and
otherwise stay on their current page.

functions.php
index.php
template-parts/glm-members-only-login-form.php

index 00cd560..6bb336b 100644 (file)
@@ -11,6 +11,8 @@ require get_template_directory() . '/inc/navigation.php';
 
 DEFINE("BLOCKS_FRONT_TOP_GROUP",69302);
 DEFINE("BLOCKS_FOOTER_AREA_GROUP",69304);
+DEFINE("MEMBERS_ONLY_PAGE_ID",get_option("glm_members_database_option_members_only_id"));
+DEFINE("MEMBERS_ONLY_LOGIN_PAGE_ID",69625);
 
 if ( ! function_exists( 'wmta_setup' ) ) :
 /**
index 35d4a78..9f1957d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -67,21 +67,18 @@ get_header(); ?>
                                                 <p><?php _e('Sorry, no posts yet');?></p>
                                                 <?php endif;?>
                                             </div>
-                                        <?php } else if (get_the_ID() == get_option("glm_members_database_option_members_only_id")) {?>
+
+                                        <?php } else { ?>
                                             
                                             <div id="main-content" class="small-12 columns">
-                                                <?php if (is_member()) {
-                                                    echo "<div class='member-profile-title'>" . get_member_name() . "</div>";
-                                                } ?>
-                                                <?php if(have_posts()) : while(have_posts()): the_post();?>
-                                                <?php the_content();?>
-                                                <?php endwhile; else:?>
-                                                <p><?php _e('Sorry, no posts yet');?></p>
-                                                <?php endif;?>
+                                                <?php 
+                                                    // Show the content of the Members Only Login page
+                                                    echo get_post_field('post_content', MEMBERS_ONLY_LOGIN_PAGE_ID);
+                                                ?>
+                                                <?php get_template_part('template-parts/glm-members-only-login-form');?>
                                             </div>
-                                            <?php get_template_part('template-parts/glm-members-only-login-form'); ?>
-                                        <?php } else { ?>
-                                            <?php get_template_part('template-parts/glm-members-only-login-form');?>
+                                            
+                                            
                                         <?php } ?>
                                     </div>
                                     
@@ -89,8 +86,8 @@ get_header(); ?>
                                             <?php wmta_entry_footer(); ?>
                                     </footer><!-- .entry-footer -->
                                 </article><!-- #post-## -->
-                        <?php } else { ?>
-                                    <div class="post-page-title"><?php echo '<h1><a href="',get_the_permalink('34'),'">',get_the_title('34'),'</a></h1>'; ?></div>
+                                <?php } else { ?>
+                                <div class="post-page-title"><?php echo '<h1><a href="',get_the_permalink('34'),'">',get_the_title('34'),'</a></h1>'; ?></div>
 
                                 <?php  if ( is_home() && ! is_front_page() ) : ?>
                                 <header>
index a24e152..933845e 100644 (file)
     <div id='glm-member-login-form'>
     <?php
     update_option('glm_members_database_frontend_login_request', 'true');
+    
+    // This attempt to control redirection gets ignored until we manage to get the Contacts plugin to force redirection to Members Only..
+    if ($post->ID === MEMBERS_ONLY_LOGIN_PAGE_ID) {
+        $redirect_target = MEMBERS_ONLY_PAGE_ID;
+    } else {
+        $redirect_target = "";
+    }
+    
     $args = array(
         'echo'    => false,
-        'form_id' => 'glm_login_form'
+        'form_id' => 'glm_login_form',
+        'redirect'=> $redirect_target
     );
     $loginForm = wp_login_form($args);
     $captcha   = apply_filters('cptch_display', '', 'glm_login_form');