Proteger el acceso al RSS de un blog de WordPress
Hay varias formas de proteger el acceso al rss de un blog de wordpress, pero lo hacen redirigiendo a la página de inicio de sesión.
En algunos lectores de feed, esto no funciona ya que requieren autenticación por http para poder agregar el feed. Este plugin permite esta opción.
< ?php
/*
Plugin Name: Silencesoft Protect RSS
Plugin URI: http://www.silencesoft.net
Description: A plugin to protect rss feeds to only registered users
Version: 1.0
Author: Byron Herrera
Author URI: http://byronh.axul.net
Copyright 2010 Byron Herrera (email : bh at axul dot net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
function sil_protect_rss() {
global $wpdb;
if (! is_feed()) return;
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="RSS Feeds"');
header('HTTP/1.1 401 Unauthorized');
echo 'This rss feeds requires authentication.';
exit;
} else {
if (user_pass_ok($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])) {
// can proceed normally
} else {
header('WWW-Authenticate: Basic realm="RSS Feeds"');
header('HTTP/1.1 401 Unauthorized');
echo 'Error on username or password.';
exit;
}
}
}
add_action('pre_get_posts', 'sil_protect_rss');
O puede descargarlo de: http://www.silencesoft.net/Wordpress/
Imprimir
Restringir acceso en WordPress
Hay una forma muy simple de proteger el acceso a un blog de wordpress, haciendo requerido el inicio de sesión del usuario.
Este simple plugin hace la tarea:
< ?php
/*
Plugin Name: Blog Users Only Plugin
Plugin URI: http://www.silencesoft.net
Description: This plugin allows you to make your WordPress site accessible to logged in and registered users only.
Author: Byron Herrera
Version: 0.1
Author URI: http://byronh.axul.net/
License: Free.
Warranties: None.
*/
function registered_subscribers_only() {
// Checks if a user is logged in, if not redirects them to the login page
if (!current_user_can('level_0'))
{
nocache_headers();
header("HTTP/1.1 302 Moved Temporarily");
header('Location: ' . get_settings('siteurl') . '/wp-login.php?action='); // logout
header("Status: 302 Moved Temporarily");
exit();
}
}
if( $pagenow != 'wp-login.php' && $pagenow != 'wp-register.php' ) add_action('template_redirect', 'registered_subscribers_only');
?>
Imprimir
Publicado Formpress 0.4 pre
Después de dedicarle tiempo a la actualización y a añadirle nuevas características al plugin Formpress de WordPress, hoy subí esta versión en línea para las primeras pruebas.
Falta agregarle bastante documentación, pero aún estoy trabajando en código así que cuando termine me pondré a organizar toda esa parte.
Igual tiene por ahí algunos "echo" que no debería, pero estoy en depuración ![]()
En WordPress
Zip
Imprimir