Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

2.4 User Information

In this lesson I’ll show you how to get information about users, with the Me and Users interfaces.

Related Links

2.4 User Information

Hello everyone, I am Reggie Dawson. Welcome to the Get Started with WPCOM.js course for Tuts+. In this video we will look at the me and users method from WPCOM.js. Now there are not many uses I could find for these particular methods, but I am sure you could probably make some use of their functionality. The users method is very simple in that all it does is offer a way to get mention suggestions for the site. I looked at the module for this method, and indeed this is all it does. Now the Me method is a bit more useful. At its most basic, it can get the metadata about the authorization token in use. It can also get information about the current user sites and likes. A good reason for you to explore the modules that make up WPCOM is that you can also find out information on message that may not be advertised in the documentation. In the module for Me I found that we can also get billing history and see information about connected apps as well. There are so many extra methods not documented that you should really look over the Me module in the WPCOM library. Now we're going to add a small function that uses a few of the Me methods, so that you can see how they work. Go back to your index.html file. First we will add a div with a button inside that will display the information we return in the console. Here we will add another div with a button inside. Then in index.js we will add our click handler for our button that we just added. Then we will add our displayMe function. Inside we use our WPCOM instance with the Me method. Then we use the Me variable with the getMethod. This will return some metadata about our token. Here all we are doing is just logging the data. Then after that, we use the Me variable with the connected apps method. This will return any connected apps that we have. After that, save your work and navigate to the project in a command line, then run beefyindex.js. Once you do that, navigate to your project in the browser, and then open up your developer's tools. Click on the Display Me information button. Now in connected apps the first item is the wordpress.com app. The second item is the app that we created and used for authentication. Then in the token info we have general information about the token such as the display name and the email of the token user. It also gives us the blog ID and the URL. Again these are not the most useful methods that we have seen, but I'm sure some developer could find some use with this functionality. In the next video, we will learn how to save media objects with our post.

Back to the top