bueltge / authenticator

This plugin allows you to make your WordPress site accessible to logged in users only.
https://wordpress.org/plugins/authenticator/
GNU General Public License v3.0
24 stars 7 forks source link

exclude page #22

Closed inetflow closed 7 years ago

inetflow commented 9 years ago

Hello,

I am searching for a possibility to exclude one page to get access directly for everyone without redirect to the login page. For example www.my-website.com/contact

How can I exclude the contact page? Which code should I use and where do I include it at the wordpress installation?

Sorry, I am not very familar with php so I had to ask.

And yes I had a look at your examples but can't figure out which one is the right one and how/where to include them. Would be nice if you could give me a hint. ;)

bueltge commented 9 years ago

Do you have read the readme, there have a documentation about the filter hook for this requirement. See also the example plugin for this hook inside the repository. https://github.com/bueltge/Authenticator/blob/master/example_plugin__exclude_posts.php

inetflow commented 9 years ago

Thanks for the fast reply, yes I did read it but I still don't know which part of the code is needed and where to include ... sorry

inetflow commented 9 years ago

May I could use this code? <?php add_filter( 'authenticator_bypass_feed_auth', '__return_true' ); But where should I include it? And do I have to change anything to fit it to only that one page?

bueltge commented 9 years ago

No, this is wrong hook. Copy the example plugin and change the title for your page, there you will exclude.

inetflow commented 9 years ago

Would this be the right code? And if so, where do I paste it? I think it wouldn't work inside the wordpress editor of the contact page? I change the page inside the code .. are the changes correct?:

<?php /**

bueltge commented 9 years ago

No, is wrong.

Copy the follow source in a file, like inetflow_exclude_page.php.

<?php
/**
 * Plugin Name: Authenticator Plugin to exclude Page "contact"
 * Plugin URI:  https://github.com/bueltge/Authenticator
 * Description: This plugin exclude the page "contact" from the Authenticator.
 * Author:      Inpsyde GmbH
 * Version:     2014-10-20
 * Author URI:  http://inpsyde.com/
 * License:     GPLv2+
 * License URI: ./assets/license.txt
 * Textdomain:  authenticator
 */

// check for uses in WP
if ( ! function_exists( 'add_filter' ) ) {
    echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
    exit;
}

add_action( 'plugins_loaded', 'authenticator_example_add_exclude' );
function authenticator_example_add_exclude() {

    add_filter( 'authenticator_exclude_posts', 'authenticator_example_exclude_posts' );
}

function authenticator_example_exclude_posts( $titles ) {

    // here goes the post-title of the post/page you want to exclude
    $titles[] = 'contact';

    return $titles;
}