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 3

Posted on October 19, 2012 by Pippin in Advanced, Tutorials, Working with Users, Writing Plugins 2 Comments
Home» Tutorials » Advanced » User Follow System – Part 3
Tweet
Love It - 2
This entry is part 3 of 5 in the Creating a User Follow System Plugin Series
← User Follow System – Part 2User Follow System Part 4 →
  • 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

In the previous part of Creating a User Follow System, we looked at the basic shell functions that we need to write for our plugin to function. Now we are going to get into actually writing those functions. We will go one by one and write each one from scratch. Also note that we will be incorporating hooks and filters in order to make our plugin extensible.

We will start by writing the two functions that retrieve the list of users a user is following and the function that retrieves of list of users that are following the user.

The pwuf_get_following() function looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
/**
 * Retrieves all users that the specified user follows
 *
 * Gets all users that $user_id followers
 *
 * @access      private
 * @since       1.0
 * @param 	int $user_id - the ID of the user to retrieve following for
 * @return      array
 */
 
function pwuf_get_following( $user_id = 0 ) {
 
	if ( empty( $user_id ) ) {
		$user_id = get_current_user_id();
	}
 
	$following = get_user_meta( $user_id, '_pwuf_following', true );
 
	return (array) apply_filters( 'pwuf_get_following', $following, $user_id );
}

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 2
  • User Follow System – Part 1
Tweet Follow @pippinsplugins
get_user_meta, update_user_meta

2 comments on “User Follow System – Part 3”

  1. Rachid Boukrim says:
    January 24, 2013 at 1:20 pm

    Hi Pippin,

    Great tutorial here, man! I really appreciate the effort you put in making this kind of tutorials and following coding and design best practices in every line of code you write.

    I went through part1, part2, and part3 of this tutorial and looking forward to part4.

    Will you be releasing part 4 of this series anytime soon?

    Thank you very much!

    Reply
    • Pippin says:
      January 24, 2013 at 1:26 pm

      I’m planning to get the next part out on Monday. Sorry for being slow :)

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 2
  • 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
  • Plugin Development 101 – Registering a Custom Post Type
  • Plugin Development 101 – Intro to Actions

Latest Tutorials

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

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

  • Plugin Development 101 – Introduction to Adding Dashboard Menus (1)

    Adding new menus, both top level and sub level, to the WordPress Dashboard is a really common task for plugins...

  • Plugin Development 101 – Intro to Loading Scripts and Styles (16)

    In this part of Plugin...

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

Latest Tweets

  • @thelukemcdonald I&#039;ll be sure to watch over my shoulder ;)
    May 22, 2013
  • @thelukemcdonald I do @rdio
    May 22, 2013
  • RT @wpthemetut: If you missed yesterday’s article - Logging wp_mail with WP_Logging http://t.co/GLR7gCxRIg
    May 22, 2013

Topics

meta box Tom McFarlin campaign monitor the_content register_setting add_options_page Rémi Corson featured attachments contextual help hook add_shortcode Sugar Event Calendar forms short codes Related posts plugin authors do_action attachment mail chimp image login recent posts apply_filters post types bbpress comments short code taxonomies custom post type Ajax images gallery 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) 2011 Pippin's Plugins