Pippins Plugins
  • Email
  • Facebook
  • Feedburner
  • Github
  • Google
  • Twitter
  • Vimeo
  • Youtube
  • Rss
  • About
  • News
  • Join the Site
    • Member Benefits
    • Member Plugins
    • Email Notifications
  • Plugin Store
    • Affiliate Area
    • Checkout
  • Plugins
    • Plugin Portfolio
      • Plugin Portfolio – List View
    • Free
    • Premium
    • Member Plugins
    • Coding Standards
    • Get Plugin Support
  • Tutorials
    • Series
      • Plugin Development 101
      • Creating a User Follow System Plugin
      • Customizing Restrict Content Pro
      • Displaying Content with Easy Content Types
      • Writing Your First WordPress Plugins, Basic to Advanced
      • Working with Widgets
      • User Submitted Image Galleries
      • Plugin Thoughts
      • Integrating Stripe.com with WordPress
      • WordPress Rewrite API
    • Member Exclusive
      • Free Members
      • Subscriber Only
    • Difficulty
      • Beginner
      • Intermediate
      • Advanced
    • Action and Filter Hooks
    • Ajax
    • Custom Post Types
    • External APIs
    • Short Codes
    • Taxonomies
    • Video Tutorials
    • Widget Tutorials
    • WordPress Admin / Dashboard
    • Working with jQuery
    • WordPress Database
    • Writing Plugins
    • Tag Index
  • Reviews
  • Support Forum
  • Contact
    • Support the Site
    • Request Code Review
    • Plugin Support

User Follow System – Part 2

Posted on October 10, 2012 by Pippin in Advanced, Member Restricted, Subscriber Only, Tutorials, Working with Users, Writing Plugins No Comments
Home» Tutorials » Advanced » User Follow System – Part 2
Tweet
Love It - 1
This entry is part 2 of 5 in the Creating a User Follow System Plugin Series
← User Follow System – Part 1User Follow System – Part 3 →
  • User Follow System – Part 1
  • User Follow System – Part 2
  • User Follow System – Part 3
  • User Follow System Part 4
  • User Follow System – Part 5

Part 1 of the User Follow System series looked at laying out the main structure of the plugin. For part 2, we’re going to continue that and lay out the main skeleton functions that we need for our plugin. These will include the functions for following a user, unfollowing a user, checking if a user followers another, and other similar functions.

There are several main tasks that happen in a plugin like this, and that’s primarily what I want to walk you through in this part of the series. We won’t write a lot of code here (we will in part 3) because it’s really important that you have a good understanding of how the logic of the system works before you jump into the code.

The Storage Method Used

There are a lot of ways to store data about users (primarily data about who is following who) and it’s important that you think about it before simply choosing one. In this tutorial series we’ll be storing the info in the WordPress user meta table. Now, there are a couple of really important notes that you need to know about this:

1. When storing in the user meta table, it is possible to make user meta global for multi site installs, or localized to individual installs. The add/get/update_user_option() set of functions is (by default) localized to individual sites. The add/get/update_user_meta() set of functions, however, is global for multi site installs, meaning that meta stored for a user on site #4 will also exist for that same user on site #7. We will be using the global option for this series, but in your own applications, this may not work.

2. By storing the data in the user meta tables, our system is persistent, meaning that all data is stored forever. Due to the way the data is stored, it is technically limited in size. All of the user IDs that one particular user is following, will be stored in the same database column and row, which means that at some point, it is possible the space will run out and no more users will be able to be followed (or some other nasty effect). In order for this to happen, a user would have to follow an exorbitant number of other users (thousands and thousands), so it is very unlikely, but still possible. If you are in a scenario where this could cause an issue, you should consider an alternate storage method.

There are three separate meta keys that will be using for storing information. One for the other users that a user is following; one for the other users that are followed by a user; one for the total number of users a user is followed by. The meta IDs will be as follows:

  • _pwuf_following
  • _pwuf_followers
  • _pwuf_followed_by_count

You must be logged in and have an active premium membership to view the rest of this content. Register or login from the sidebar.


Related Items
  • User Follow System – Part 3
Tweet Follow @pippinsplugins
add_user_meta, add_user_option, get_user_meta, get_user_option, update_user_meta, update_user_option

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Login

Lost your password?

Please enter your username or e-mail address. You will receive a new password via e-mail.

  • Facebook Become a Fan Like

  • Twitter Subscribe on Twitter Follow

  • YouTube Follow my Videos Subscribe

  • RSS Feed Subscribe with RSS Subscribe

Easy Digital Downloads

Most Loved

  • Love It Pro for WordPress
  • Write a “Love It” Plugin with Ajax to Let Users Love Their Favorite Posts / Pages
  • Simple Notices Pro Plugin for WordPress
  • User Bookmarks for WordPress
  • Front End Registration and Login Forms Plugin

Similar Plugins and Posts

  • User Follow System – Part 3
  • Review: Easy User Fields
  • Add Custom User Meta Fields to Restrict Content Pro Registration

Latest Premium Content

  • Plugin Development 101 – Introduction to Adding Dashboard Menus
  • Plugin Development 101 – Intro to Loading Scripts and Styles
  • User Follow System – Part 5
  • Plugin Development 101 – Intro to Short Codes

Latest Tutorials

  • Storing Session Data in WordPress without $_SESSION (19)

    The term Session in web development refers to...

  • Test Your Plugins with RTL (1)

    Right-To-Left languages are those that...

  • Submitting Your First Pull Request to a WordPress Plugin on Github (5)

    Github is an extremely popular tool for managing WordPress plugins, and one...

Enter your email to receive automated updates when new posts are published

WP Core Contributions

  • [24316]

View the ticket on Trac.

WP Codex Contributions

  • Function: shortcode exists
  • Function: has shortcode
  • Function: shortcode exists
  • Function: shortcode exists
  • Function: has shortcode

View all 41 changes in the Codex.

Latest Tweets

  • Could not fetch Twitter RSS feed.

Topics

the_content get_user_meta Sugar Event Calendar campaign monitor add_options_page attachments wp_enqueue_script Rémi Corson shortcodes register_setting featured hook add_shortcode Related posts do_action plugin attachment mail chimp image forms login short codes authors apply_filters recent posts comments post types bbpress short code taxonomies custom post type images gallery Ajax Stripe taxonomy jquery users widgets add_filter easy content types add_action widget restrict content pro easy digital downloads

Weekly Newsletter

Useful Links

  • Join the Site
  • Plugin Store
  • Affiliate Area
  • Tag Index
  • Support the Site
  • Suggest a Tutorial
  • Random Post
  • Contact

Monthly Archives

(c) 2013 Pippin's Plugins