This entry is part 3 of 5 in the Creating a User Follow System Plugin Series
- 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

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!
I’m planning to get the next part out on Monday. Sorry for being slow