• Resolved isaacbenh

    (@isaacbenh)


    I have a registration form which I want to load via short-code, but I’m having trouble rendering it properly. In some places it prints my php tags like they were part of the text.
    On purpose I’m not including it all, because it will just be too long.
    What am I doing wrong? Maybe quote signs messed things up?

    add_shortcode( 'register-form', 'register_form' );
    
    function register_form()
    {
    return '
    
        <div class="col-md-8 col-md-offset-2" style="margin-top: 50px;">
            <div class="panel panel-primary">
                 <div class="panel-heading">Register</div>
                 <div class="panel-body additional-fields-panel">
    
                    <form action="/coverager/register-user" class="form-horizontal" method="post">
                        <input type="hidden" name="user_noncename" id="user_noncename" value="<?php echo wp_create_nonce( get_template_directory_uri( __FILE__ ) ) ?>" />
    
                        <div class="<?php echo "form-group" . ( errorsHas("username") ? " has-error" : "" );  ?>">
                            <label for="username" class="col-md-4 control-label">Username:</label>
                            <div class="col-md-6">
                                <input type="text" class="form-control" name="username" value="<?php old("username"); ?>">
    
                                <?php if( errorsHas("username") ): ?>
                                    <span class="help-block">
                                        <strong><?php echo $_SESSION["errors"]["username"]; ?></strong>
                                    </span>
                                <?php endif; ?>
    
                            </div>
                        </div>
    
                        <div class="<?php echo "form-group" . ( errorsHas("email") ? " has-error" : "" );  ?>">
                            <label for="email" class="col-md-4 control-label">Email:</label>
                            <div class="col-md-6">
                                <input type="text" class="form-control" name="email" value="<?php old("email") ?>">
    
                                <?php if( errorsHas("email") ): ?>
                                    <span class="help-block">
                                        <strong><?php echo $_SESSION["errors"]["email"]; ?></strong>
                                    </span>
                                <?php endif; ?>
    
                            </div>
                        </div>
    
                    </form>
                </div>
            </div>
        </div>
    ';
    
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add a form as a shortcode’ is closed to new replies.