"You need to be a member of PlayStation Plus or have a local user account on the subscriber’s ‘Primary PS4’ to play many games online. You can find full details of what PlayStation Plus features you can share with your friends here.
If you are on reddit, you might consider subscribing to the PS4deals subreddit. You can often find PS+ annual subscriptions for ~$40 instead of the $50 that Sony charges. When you add in the free games, even if some of them aren't great, it's a pretty good deal.