• Hello,
    I added this function to get a list of all the post consistent with user categories

    add_action( 'request', 'my_request' );
    function my_request($request) {
    	if(empty($request["cat"]) && is_admin() && strpos($GLOBALS['PHP_SELF'],"/wp-admin/edit.php") && !in_array('administrator', $currentUser->roles) && isset($request['post_type']) && $request['post_type']=='post'){
    		$currentUser = wp_get_current_user();
    		$include = get_user_meta( $currentUser->ID, '_access', true);
    		$request["cat"]=implode(",",$include);
    	}
    	return $request;
    }

    https://www.ads-software.com/plugins/restrict-author-posting/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Alberto Timossi

    (@timox3d)

    … correct code…

    add_action( 'request', 'my_request' );
    function my_request($request) {
    	$currentUser = wp_get_current_user();
    	if(empty($request["cat"]) && is_admin() && strpos($GLOBALS['PHP_SELF'],"/wp-admin/edit.php") && !in_array('administrator', $currentUser->roles) && isset($request['post_type']) && $request['post_type']=='post'){
    		$currentUser = wp_get_current_user();
    		$include = get_user_meta( $currentUser->ID, '_access', true);
    		$request["cat"]=implode(",",$include);
    	}
    	return $request;
    }
    Plugin Author Jam Viet

    (@mcjambi)

    i will check and add to plugin if this function is userful for most case, and i will give your name to contributer list !

    Thanks my friend so much !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get a list of all the post consistent with user categories’ is closed to new replies.