include('index.php') not working external script

Permalink
Hey guys,

I've been trying stuff for hours, I haven't found a good answer anywhere.

I have a payment page, after a successful payment I want to add the customer to my membership website, build with Concrete5.

The payment page is created with an external script, so I need to be able to add users from that script, using the Concrete5 functions.

I found that I needed to add this to be able to use Concrete5 code in the external script, but it doesn't work.

<?define('C5_ENVIRONMENT_ONLY', true);
include('index.php');
?>


This is the structure of my folders and files:
root/
index.php
/folder
external.php

After the obvious tries, index.php still didn't load, now I have this:

echo 'check 1';
define('DIR_BASE', '../');
define('C5_ENVIRONMENT_ONLY', true);
include('../index.php');
echo 'check 2';
?>


Now I don't get any more errors, however, everything after 'include('../index.php');' doesn't load. That's why I added 'echo 'check 2';' to see if everything works.

I want to know what I'm doing wrong. Why doesn't it load? I tried to load a different php file with a simple echo in it and it showed up no problem.

To add a user I use this code:

<? use Concrete\Core\User\UserInfo;
$user = \UserInfo::add(['uName' => 'andrafew', 'uEmail' => 'andrew@concrete5.org', 'uPassword' => 'kittens']); ?>


I tested this out, it should work if it would load.

 
Gondwana replied on at Permalink Reply
Gondwana
I did a fairly similar thing, but in a rather different way.

In application/config/app.php, I have:
Route::register('/slideshow/api/register', '\Application\Controller\Frontend\Api::register');


In application\controllers\frontend\api.php, I have:
<?php
namespace Application\Controller\Frontend;
use Controller;
defined('C5_EXECUTE') or die('Access Denied.');
class Api extends Controller {
    public function register() {
        $request = json_decode($_POST['json']);  // really shouldn't use $_POST
        // code to actually register the user, like you've already got
        ...


The register() function can then be called via the slideshow/api/register URL.