WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Outputting only an array with WordPress user data for an external application? (10 posts)

  1. Scoodle
    Member
    Posted 2 years ago #

    Hi there,

    In order to connect WordPress to my forum, which is running on the Vanilla platform, I need to provide a link to a page which will only output WordPress user data, nothing more. I know how to output the data in a place where I have access to the WordPress codex functions, but I haven't got a clue how to set up a page which will have only the array on it, just saying something like

    {"email":"someone@example.com","name":"John Doe","photourl":"","uniqueid":"123456","client_id":"1234567890",
    "signature":"abcdefghijklmnopqrstuvwxyz"}

    .

    How should I go about putting this piece of code, which can generate the array to be returned, on a page with nothing else on it (so only the array will be returned) and with access to the WordPress codex functions it relies on?

    Thanks in advance!

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    which is running on the Vanilla platform

    What is the Vanilla platform? Do you mean that you are using the Twenty Eleven theme and no plugins?

  3. Scoodle
    Member
    Posted 2 years ago #

    Sorry for not explaining that. It's a separate forum system which is simply called 'Vanilla', and provides single sign-on (SSO) support to work with external user databases.

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    Would a custom page template work for this?

  5. Scoodle
    Member
    Posted 2 years ago #

    Thanks for the link, I've made a theme that will only output user data and put it in its own directory in the themes folder, along with a Vanilla PHP library that it requires.

    Obviously, I don't want to apply this template to my entire WordPress site. I can't even do that because a .css file is apparently also required (one with only the theme name made it disappear from the theme management page, leaving it out makes WordPress say it's missing). How should I link to it? Did I do something fundamentally wrong here?

    Appreciate your help.

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Are you sure that you are not confusing "theme" with "page template". One theme can hold multiple page templates.

  7. Scoodle
    Member
    Posted 2 years ago #

    Perhaps I am. I've now put my page template (and the Vanilla PHP library, again) in the directory of the theme I actually use, instead of treating it as a theme on its own. Still can't figure out how to call upon the page (template), though. Tried just going to /wp-content/themes/THEME-I-USE/userdata.php (userdata.php being the name of my page template), but the WordPress functions don't get recognized this way: Fatal error: Call to undefined function.

  8. esmi
    Forum Moderator
    Posted 2 years ago #

    The page template file needs to site within your theme's folder in wp-content/themes. The Vanilla PHP library could go in the wp-content folder (just remember to amend any file paths in the page template) which would protect it from being deleted by any accidental theme update.

    Once that's all sorted, create a new blank page called (for example) Forum, simply apply your new page template using the Page Template dropdown on Add New Page and publish the page. And that should be it!

  9. Scoodle
    Member
    Posted 2 years ago #

    Great, thank you so much!
    Now I just need to find a way of hiding the page from the pages menu (this official tutorial didn't work for me, child pages show up in my theme), but that's another problem entirely. I consider this topic's problem [SOLVED], cheers!

  10. esmi
    Forum Moderator
    Posted 2 years ago #

    The easiest option would be to create a custom menu. Failing that, post a new topic with the code snippet that is generating your page menu (try looking in header.php or sidebar.php). There should be a fix but it will be dependant upon what is being used to generate that menu.

Topic Closed

This topic has been closed to new replies.

About this Topic