Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4050330
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:03:24+00:00 2026-05-20T14:03:24+00:00

A WP user with the role Author can post articles. On the blog in

  • 0

A WP user with the role “Author” can post articles. On the blog in question I have the requirement, that these users’ articles have to be live immediately but not publicly visible (i.e., for anonymous visitors or Subscribers). We use WP 3.0.5.

We already have a plugin running, that allows to hide categories from anonymous and Subscribers. So the most straight-forward method I came up with so far is: New blog posts by Authors should be automatically put in a category. Then I hide that category from anonymous users.

Does anyone know:

a) how to automatically put an article by “Author” users in a certain category, or

b) how the requirement “live but not public” could be achieved more elegantly for those posts?

(Plugin suggestions are welcome, too.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:03:25+00:00Added an answer on May 20, 2026 at 2:03 pm

    What you probably want to do is write function to do this in your theme’s functions.php file, and then use add_action to trigger that function when a post is saved.

    For example:

    function update_category_on_save($post_id) {
        // Get post
        $post = wp_get_single_post($post_id)
        // Map author IDs to category IDs
        $mapping = array(
            1 => array(123),
            2 => array(234),
        );
        // Update the post
        $new_category = $mapping[$post->post_author];
        $u_post = array();
        $u_post['ID'] = $post_id;
        $u_post['post_category'] = $new_category;
        // Only update if category changed
        if($post->post_category != $new_category[0]) {
            wp_update_post($u_post);
        }
    }
    
    add_action('category_save_pre', 'update_category_on_save');
    

    Hope that makes sense, and gives you a hint as to how to do this — I’m afraid I haven’t been able to test it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing roles. Many users can be assigned to a role.
I have a HABTM association between user and role. User can be an admin
Imagine that users can have one or more roles in the system. after login
What are the standard user role names that a majority of sites could all
Hi i have an entity called User with 2 properties called UserName and Role
can I use it like this in View? <%= Html.CheckBoxFor(user => user.Role, Administrator)%> and
I have the following if statement: if !projectid_viewing.nil? && !user.role(projectid_viewing).nil? && user.role(projectid_viewing) == 'admin'
I have the following models to associate users with roles: class User < ActiveRecord::Base
I have a Nhibernate mapping file for a simple user/role mapping. Here are the
I have a table that has a relationship between an User_ID and a Role.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.