WordPress.org

Ready to get started?Download WordPress

Forums

Restrict Categories
Restricting categories for users programmatically (2 posts)

  1. acoelhosantos
    Member
    Posted 1 year ago #

    Let me start by saying good job in this plugin. For me, it works perfectly and I have no problems with it.

    I was now wondering if besides the normal admin page, if there is a defined way for restricting categories through php code (programmatically). My intent is to automatically restrict categories when a user registers in the site.

    Thanking you in advance for any help.

    http://wordpress.org/extend/plugins/restrict-categories/

  2. valuser
    Member
    Posted 1 year ago #

    Would playing around with this be of any help

    function onlyinclude_tag($query) {
    if ( $query->is_home() && is_user_logged_in()) {
    	$query-> set('category__in',array('green'));
    	}
    return $query;
    }
    add_filter('pre_get_posts','onlyinclude_tag');

    Change the if conditions and the category (green) to suit you

    and place function in the functions.php of your theme

    see also http://codex.wordpress.org/Class_Reference/WP_Query

    May help

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic