0

I want to change specific page so that non-member users will be faced with a form that they can register with, and also this page wouldn't look like the others, I mean this page must be totally different to other pages because of my HTML code. But I don't have any idea how to implement it. For example in my plugin I wrote this code:

function ok() {
if (is_page('get-messages')){
    $user = wp_get_current_user();
    foreach ($user->roles as $role) {
        echo "$role<br>";
    }
    echo get_settings('siteurl') . '/get-messages';
    if ( !is_user_logged_in() ) {
        ?>
        <form method="get" action="">
        <input type="submit" value="ok">
        </form>
        <?php
    }   
}

} 
add_action('template_redirect', 'ok');

what i must write in if(!is_user_logged_in()) so that my plugin don't let to page loads its template and only show my html code. I appreciate your help

  • 1
    Please explain your question more deeply. – Vinod Dalvi Aug 18 '13 at 19:06
0

I think you want a custom page template.

  1. Create a custom page template.
  2. In that page template paste your code.
  3. Create a "Page" from wp_admin->Pages and select your template file as the "Template"

In your page template, you would have something like this:

/*
Template Name: My Custom HTML Page
*/
get_header();

get_footer();

Leave out the get_header and get_footer and you will have a page that loads in WordPress but without most of the theme structure.

  • this is good but i want do this with plugin not template – user1695063 Aug 19 '13 at 4:45
  • Then use template_redirect or template_include to load the code-- like this. If you want more help, edit the question to be more descriptive of the problem. As written, answering your question is basically guesswork. – s_ha_dum Aug 19 '13 at 4:49
  • thanks. with your help and tutorial in this link I've made a specific page. – user1695063 Aug 19 '13 at 9:25

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.