Well, BlogMemberExtension applies to the Member class, which provides you with an easy way to access member posts through the many-to-many association.
I assume that this function will not be in the Member extension, and that you will pass the identifier of the element, since it is no longer present in your code. This assumption may not be correct, since your method is called " My RecentPosts", but in any case - here is an example:
public function MyRecentPosts($memberId) { $member = Member::get()->byId($memberId); $posts = $member->BlogPosts() ->sort('PublishDate', 'desc') ->limit(2); return $posts; }
You can also do this from the BlogPost model through your many many many association:
$posts = BlogPost::get() ->filter(array('Authors.ID' => $memberId)) ->sort('PublishDate', 'desc') ->limit(2);
source share