Cómo restringir el acceso a los posts para no registrados

  • Autor Autor TheLukasWeb
  • Fecha de inicio Fecha de inicio
T

TheLukasWeb

Beta
Diseñador
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Hola, tengo graves problemas porque el plugin s2member me ha dejado de funcionar y no hay forma de arreglarlo y no encuentro uno que me haga lo qu quiero. Quiero restingir la entrada a los posts para los no registrados y que cuando intenten entrar sean redireccionados a una página, pero que puedan ver un estracto en el index. Lo he intentado con un condicional en la plantilla del single.php pero me lo hace tambien en las paginas y entran en un bucle:
post -> página de redirección -> página -> página -> ...
Gracias!

HECHO! Ya lo he resuelto, el condicional en la plantilla de single.php es la solucion y el problema era un fragmento de codigo del fuctions.php de mi theme. Gracias!

P.D.: Si quereis pongo el codigo exacto.
 
Última edición:
A mi me gustaría mucho que compartierás el código, tal vez, algún día lo necesite... 🙂
 
Última edición:
Este es mi single.php original:
Insertar CODE, HTML o PHP:
<?php get_header(); ?>

<div id="content" class="section">
<?php arras_above_content() ?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
	<?php arras_above_post() ?>
	<div id="post-<?php the_ID() ?>" <?php arras_single_post_class() ?>>

        <?php arras_postheader() ?>


        <div class="entry-content clearfix">
		<?php the_content( __('<p>Read the rest of this entry &raquo;</p>', 'arras') ); ?>  
        <?php wp_link_pages(array('before' => __('<p><strong>Pages:</strong> ', 'arras'), 
			'after' => '</p>', 'next_or_number' => 'number')); ?>
		</div>


		<?php arras_postfooter() ?>

        <?php 
		if ( arras_get_option('display_author') ) {
			arras_post_aboutauthor();
		}
        ?>
    </div>
    
    
<?php endwhile; else: ?>

<?php arras_post_notfound() ?>

<?php endif; ?>

<?php arras_below_content() ?>
</div><!-- #content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Ahora le añadimos el condicional y cambiamos la dirección a la que queremos que nos redirija: (lo de azul es la redireccion)
Insertar CODE, HTML o PHP:
<?php get_header(); ?>

        [COLOR="red"][SIZE="4"][B]<?php global $user_ID, $user_identity, $user_level ?>
        <?php if ( $user_ID ) : ?>[/B][/SIZE][/COLOR]

<div id="content" class="section">
<?php arras_above_content() ?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
	<?php arras_above_post() ?>
	<div id="post-<?php the_ID() ?>" <?php arras_single_post_class() ?>>

        <?php arras_postheader() ?>


        <div class="entry-content clearfix">
		<?php the_content( __('<p>Read the rest of this entry &raquo;</p>', 'arras') ); ?>  
        <?php wp_link_pages(array('before' => __('<p><strong>Pages:</strong> ', 'arras'), 
			'after' => '</p>', 'next_or_number' => 'number')); ?>
		</div>


		<?php arras_postfooter() ?>

        <?php 
		if ( arras_get_option('display_author') ) {
			arras_post_aboutauthor();
		}
        ?>
    </div>
    
    
<?php endwhile; else: ?>

<?php arras_post_notfound() ?>

<?php endif; ?>

<?php arras_below_content() ?>
</div><!-- #content -->

[COLOR="red"][B][SIZE="4"]<?php elseif ( get_option('users_can_register') ) : ?>

[COLOR="blue"]<script type="text/javascript"> 
window.location="http://DIRECCION/"; 
</script>[/COLOR]

<?php endif // get_option('users_can_register') ?>[/SIZE][/B][/COLOR]

<?php get_sidebar(); ?>
<?php get_footer(); ?>
 
Última edición:
Atrás
Arriba