Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There's a specific category on my website that should be restricted to teachers only using login. However, I don't want to hassle the teachers with the not so welcoming admin Wordpress offers. I would like to offer a "lightbox" that's basically a login that doesn't automatically forward to the admin, but only makes the teachers category content available. Do you know any plugin that allows that? Thanks, Sarit

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Don't know about a plugin that does that for you but you can use the WordPress native Thickbox:

enter image description here

First include the Thickbox script and style in your category only if the user is not logged in (simply copy/paste in your theme's functions.php file)

function add_thickbox_script_and_style(){
    if(is_category('YOUR_CATEGORY') && !is_user_logged_in()){
        wp_enqueue_script('jquery');
        wp_enqueue_script('thickbox',null,array('jquery'));
        wp_enqueue_style('thickbox.css', '/'.WPINC.'/js/thickbox/thickbox.css', null, '1.0');
    }
}
add_action('init','add_thickbox_script_and_style');

Then open up your category.php (or archive.php depending on your theme , or even better is a custom file for that category category-id.php) and add this code before the loop:

if (is_category('YOUR_CATEGORY') && !is_user_logged_in()){
    echo '<div id="lform" style="display:none;">';
    wp_login_form();
    echo '</div>';
    echo 'Please <a class="thickbox" href="#TB_inline?height=200&width=200&inlineId=lform">Login</a> to see the content';
}else{


//your loop goes here

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.