0

I am relatively new to Wordpress, but have been doing a fair bit of PHP programming.

My question is: is it possible to have a front end powered by Wordpress only, for registration/login/authorisation purposes only, so only paid-up, registered users can view restricted content, but have the restricted content composed of only pure, non-Wordpress (i.e PHP in this case) files/classes/directories etc?

I ask this question as there seem to be no end of hoops to jump through if you want to use inheritance, composition etc of classes and objects and display output in a Wordpress page. Thanks in advance

  • 1
    as the answers so far imply, your question is very broad. As with most software development frameworks, (almost) everything can be done which doesn't mean it make sense to do it, or to do it in the specific way you envision. You should try to ask a more specific question if you would like to get more useful answers. – Mark Kaplun Aug 30 '16 at 5:45
  • Thanks Mark for your reply. Basically, I have a fully-working PHP site which is a revision site, with questions & answers. I also have various bits of Javascript code to do some work client-side within the pages. All good. – piscean111 Sep 2 '16 at 13:00
  • But I find not all works with WP, even after using various helpful plugins. So my aim is:1] users logged in/authorised by WP 2] get redirected to my PHP pages (which I know work) 3] these pages restricted, so non-authorised users can't access. As my primary aim is to develop content and get it out there, I am happy to use WP for the technical side of registering/logging in etc - but seem to get many issues where my original pages do not work properly in the WP environment. – piscean111 Sep 2 '16 at 13:28
4

It is a little hard to grasp how much of WordPress you really want to replace.

WordPress at front-end will typically take care of following steps:

  • parse the requested URL (typically "pretty")
  • determine the current context of request (query variables)
  • query the required set of posts
  • determine and load which theme template fits bets
  • proceed to load template and have it output the posts queried

Obviously with all the usual goodies of user management and various APIs for various tasks on top. Simply put — WP does a lot of stuff.

Much of this can be disabled, customized, and overall done in different ways.

Without thorough research of specific use case it is hard to advise on which specific parts (if any) of the process should be customized and how.

In a nutshell — yes, you can get rid of WP on front end. But that get rids of a lot of valuable bits (it is used for in first place) and it depends.

  • Thanks Rarsi. Yes I still need WP to do all the heavy lifting, but as my priority is to get my content out there, and not spend too much time on finding out what works or doesn't work with WP, I thought I would ask my original question – piscean111 Sep 2 '16 at 13:18
1

Of course it is possible to have non-WordPress pages inside a directory where WP is installed. The question is how those PHP pages would know a user is logged in in WP. That would involve at least some check in the WP database.

Another approach I can think of (but which may not be tamper proof) is to use the .htaccess file to deny access to the restricted content directory, unless the referrer is another file in that directory or the user profile page in the WP install.

1

Use the following in your native PHP script:

<?php
require('/the/path/to/your/wp-blog-header.php');
?>

This will load the scripts, functions etc. You can then make calls to is_user_logged_in() to protect your non-WordPress pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.