0

I want to create a URL to an activation page in Wordpress. But I don't want to create a page for it with a shortcode. So it must be a dynamic page.

I'm currently trying to see if I can do it with a REST API. And so far activation has been successful. I have created a REST route and I get the activation code (which is part of the link) as a variable. But I cannot show a page with a message that the activation was successful, not within the chosen theme. All HTML I send to the browser is displayed on a black page, without the theme.

I'm starting to wonder if I'm on the right path, or is the REST API intended for something else?

This is what I have so far:

$this->loader->add_action( 'rest_api_init', $plugin_public, 'course_add_enpoint');

public function course_add_enpoint(){
  register_rest_route('course_manager/v1', 'activation/(?P<id>[A-Za-z0-9]+(_[A-Za-z0-9]+)+)', array(
            'methods' => 'GET',
            'callback' => array ($this, 'course_activation'),
    ));
}

public function course_activation( $data ){
        returns HTML code
}

So far the activation works, but the page with HTML code is not the same as a page with the layout of the theme. Can someone point me in the right direction, am I working with the REST API or should I look elsewhere?

1 Answer 1

0

OK, I found a page how to create a fake page and it's exactly what I needed: https://geek.hellyer.kiwi/2018/creating-fake-wordpress-pages/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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