0

I have bought a wordpress template but the developers say they cannot help me with what I need.

The theme has a hotel reservation system integrated, and the form brings a field to “place” the user email, however this option is disabled, only a Text appears that says “Need to be logged in” but when I click over there nothing happens.

I guess that email field should at least take me to a page (maybe user registration), or at least that's what I wish to happen.

I've been reviewing the PHP code of that form, but I really don't know what to do because I don't handle PHP, I don't know how I could solve this issue.

I tried several times to fix that by adding an a href= but nothing happens.

Is there someone who could please help me or tell me what to do?

This is the code of that php field on the form:

<span class="mkdf-input-email">
                    <label><?php esc_html_e( 'Email:', 'mkdf-hotel' ) ?></label>
                    <input type="text" class="mkdf-res-email" name="user_email" placeholder="<?php esc_attr_e( 'Need to be logged in', 'mkdf-hotel' ) ?>" disabled value="<?php echo esc_attr($email) ?>" />                    </span>

I would like to add this url link (https://www.mayanhills.com/cuenta-de-usuario) on the `Need to be logged in’ text field.

Here is the page link to see the form if you want to do that:

http://www.mayanhills.com/hotel-room/habitacion-sencilla/

Sorry about my english, hope somebody can understand and help me please.

Thank you so much

3
  • Looks like you need JavaScript/jQuery and not PHP. The input field is disabled, so the logic would be to (1) check if input.mkdf-res-email is disabled, and (2) if yes, then onclick go to the required href. Jan 2, 2022 at 16:30
  • Thank you so much Pat, where can I check and edit that input to check if is disabled? I´m so sorry, I don´t know where to do that... I hope finding it maybe I could edit as you told me... Thanks a lot
    – Jeovanny
    Jan 2, 2022 at 18:54
  • answer below. Please update what worked - thanks! Jan 5, 2022 at 14:34

2 Answers 2

0

I think your website works as it should be, because:

  1. I see what you see, there's no way to book the room. Booking
  2. To access to the booking functionality, you must to register your self at http://www.mayanhills.com/registro-de-nuevo-usuario/, there's a window like this one Form.
  3. Then you log in. Login form
  4. Then you go back to the booking place... And there you go: enter image description here

I think it works perfect, now if you want to change that or at least send you to the registration form you should modify with PHP with something like this.

<?php if ( is_user_logged_in() ) { ?>
<span class="mkdf-input-email">
    <label><?php esc_html_e( 'Email:', 'mkdf-hotel' ) ?></label>
    <input type="text" class="mkdf-res-email" name="user_email" placeholder="<?php esc_attr_e( 'Need to be logged in', 'mkdf-hotel' ) ?>" disabled value="<?php echo esc_attr($email) ?>" />
</span>
<?php } else { ?>
    <a href="<?php echo esc_url( wp_login_url( get_permalink() ) ); ?>" class="mkdf-res-email" alt="<?php esc_attr_e( 'Login', 'textdomain' ); ?>"><?php _e( 'Login', 'textdomain' ); ?></a>
<?php } ?>

I hope that helps you. ;D

UPDATE

With the code you sent me I did this:

<div class="mkdf-hotel-room-reservation" data-room-id="<?php echo get_the_ID(); ?>">
    <form id="mkdf-hotel-room-form" method="POST">
        <?php wp_nonce_field('mkdf_hotel_room_booking_form', 'mkdf_hotel_room_booking_form'); ?>
        <div class="mkdf-grid-row">
        
        <!-- New code -->
        <?php if ( is_user_logged_in() ) : // Verify if current user is logged in, if so; show the input with the email. ?>
            <div class="mkdf-grid-col-12">
                <span class="mkdf-input-email">
                    <label><?php esc_html_e( 'Email:', 'mkdf-hotel' ) ?></label>
                    <input type="text" class="mkdf-res-email" name="user_email" placeholder="<?php esc_attr_e( 'Need to be logged in', 'mkdf-hotel' ) ?>" disabled value="<?php echo esc_attr($email) ?>" />
                </span>
            </div>
        <?php elseif: // In case the current user is not known, show the registration link.  ?>
            <style>
                /* If possible, move these styles to the styles.css */
                .mkdf-unkown-user{
                    width: 100%;
                    margin: 0;
                    padding: 12px 40px;
                    font-family: inherit;
                    font-size: 15px;
                    line-height: 30px;
                    font-weight: inherit;
                    color: #afafaf;
                    background-color: transparent;
                    border: 1px solid #555;
                }
            </style>
            <div class="mkdf-grid-col-12">
                <a href="<?php bloginfo('descriurlption'); ?>/registro-de-nuevo-usuario/" class="mkdf-unkown-user" alt=""><?php _e( 'Login', 'textdomain' ); ?></a>
            </div>
        <?php endif; ?>
        <!-- End new code -->
           
9
  • Thank you so much @LaJennyLove This is a great help to me. The thing is I would like in the field where says ¨Need to be logged in¨ i want do a click to go to that login or registration page. I will try this... Thanks a lot
    – Jeovanny
    Jan 2, 2022 at 20:49
  • Well, with the code I left you here... First check if the user is logged in; in case the user is logged in, it shows the field as it should be, but if the user is not logged in, then it shows the link to go to the register page. Jan 2, 2022 at 20:56
  • Thanks a lot @LaJennyLove I´m trying it right now, I´ll tell you anything. Again, thank you so much
    – Jeovanny
    Jan 2, 2022 at 21:00
  • This should will go to the wp-login.php page right? how can I do to go to this page: mayanhills.com/registro-de-nuevo-usuario
    – Jeovanny
    Jan 2, 2022 at 21:02
  • @Jeovanny Instead of use <a href="<?php echo esc_url( wp_login_url( get_permalink() ) ); ?>" class="mkdf-res-email" alt="<?php esc_attr_e( 'Login', 'textdomain' ); ?>"><?php _e( 'Login', 'textdomain' ); ?></a> use this: <a href=mayanhills.com/registro-de-nuevo-usuario" class="mkdf-res-email" alt="Need to be logged in">Need to be logged in</a> Jan 3, 2022 at 0:35
0

You need to check if the input field is disabled. This means the user is not logged in.

If it is disabled, then you add a link to the container using jQuery that, when clicked, will take the user to the registration/login page.

Put this javascript/jQuery at the bottom of your page to achieve this:

<script>
    jQuery(document).ready(function ($) {
        if ($("input.mkdf-res-email").prop('disabled')) {
            $("span.mkdf-input-email").on('click', function () {
                window.location.replace('http://www.mayanhills.com/registro-de-nuevo-usuario/');
            });
        }
    });
</script>

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.