WordPress.org

Ready to get started?Download WordPress

Forums

Possible for such function to be implemented via plugin? (3 posts)

  1. heshiming
    Member
    Posted 1 year ago #

    I'm implementing a custom wordpress site via plugin. I'm wondering whether the following functions can be done. And if so, how do I go about implementing them.

    Custom post. I need to create a custom post type with custom fields. How do I implement:

    • 2-level hierarchy of category for each post. How do I put up a page that views paged latest posts by category, or by date, or in random order?
    • association of custom user data with the each post, to record info such as whether a user has read it or his comment. I'm thinking about implementing another 'custom post type' for this. Is this a good approach? How do I put up a page for the user to see everything he already read, or didn't read?
    • a filter / search tool that combines the function of filtering by read/unread, and the contents of comments and posts

    A permission system. I need to define 3 levels of permission for each custom post. They are: 1. publicly viewable, 2. viewable after registration, 3. viewable after purchase. I'll put this limit on the single post page only. User can purchase content on a category basis (which is a custom field of the post). I'm wondering if using custom user setting is a good approach to implement this function.

    I have a general understanding of wordpress and PHP. I read a book about plugin development but I've never done it. Any help is appreciated.

  2. bcworkz
    Member
    Posted 1 year ago #

    Categories are stored as post meta. You can pretty much organize them how you want, but the meta table is flat, so you'd have to manage the organization yourself. Consider using taxonomy instead, it has a parent child structure that gives you much flexibility.

    Consider storing custom post data with each user instead of the other way around. Just makes more sense to me. In the end, it probably doesn't matter, you use either post meta or user meta. No need for some special post hack to implement either way. You are limited on how to display data only by your ability to construct a mysql query to find and organize the data. You typically would use WP_Query objects to do this, but there's a generic db global access object called $wpdb for anything you can't do with WP_Query.

    Out of the box, WP only has a public/private viewing structure. You can create any combination of user roles and capabilities to manage access. Custom view access is easiest done at the template level, but as a plugin, that's off limits. There's probably a number of approaches via filter and action hooks to manage access.

    For example, you could filter 'the_content' just before it is sent to the client, and if the client has the wrong capability, you send an error message instead of the content.

  3. heshiming
    Member
    Posted 1 year ago #

    I'll research a bit more on taxonomy. Thank you for the information.

Topic Closed

This topic has been closed to new replies.

About this Topic