• Resolved dennyspirit

    (@dennyspirit)


    Hello,

    i want to include also a “name” form instead of just the “mail adress” form for subscribers.

    How can i enable this?

    i found out that in the subscribe.js file there is already a “cs_name” included, but i can’t get it to work, if i include it to the glass.php file.

    it would be nice if you could help me out with that.

    thank you.

    UPDATE: already solved… i added the solution below. Thank you.

    • This topic was modified 7 years, 9 months ago by dennyspirit.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dennyspirit

    (@dennyspirit)

    I included this in the glass.php:

                            <div class="row subscribe <?php echo (($the_cs_template_options['subscribe']) == 1) ? '' : 'hidden' ?>">
                                <div class="col-sm-8 col-sm-offset-2">
                                    <div class="subscribe input-group">
    
                                      <input type="name" id="cs_name" class="form-control" placeholder="<?php _e('Your Name', CSCS_TEXT_DOMAIN); ?>">
    
                                        <input type="email" id="cs_email" class="form-control" placeholder="<?php _e('Your email address', CSCS_TEXT_DOMAIN); ?>">
                                        <span class="input-group-btn">
                                            <button class="btn btn-default subscribe-btn" id="subscribe-btn"  type="button"><?php echo CSAdminOptions::getDefaultStrings('subscribe_text'); ?></button>
                                        </span>
                                    </div>
                                </div>
                            </div>
    
    • This reply was modified 7 years, 9 months ago by dennyspirit.
    Thread Starter dennyspirit

    (@dennyspirit)

    and edited the script below in glass.php to this:

    
            <script>
    
                jQuery('.subscribe-btn').on('click', function () {
    
                    subscribe();
    
                });
    
                jQuery('#cs_email, #cs_name').on('keypress', function (e) {
    
                    if (e.which == 13) {
    
                        subscribe();
    
                    }
    
                });
    
                function subscribe() {
    
                    jQuery.ajax({
    
                        url: '<?php echo admin_url('admin-ajax.php'); ?>',
    
                        data: {action: 'subscribe_email', cs_email: jQuery("#cs_email").val(), cs_name: jQuery("#cs_name").val()},
    
                        dataType: 'json',
    
                        success: function (data) {
    
                            if (data['error']) {
    
                                jQuery('.error-msg #error-msg-text').html(data['message']);
    
                                jQuery('.error-msg').removeClass('hidden');
    
                                jQuery('.error-msg').addClass('animated fadeIn');
    
                                function hideMsg() {
    
                                    jQuery('.error-msg').addClass('fadeOut');
    
                                }
    
                                setTimeout(hideMsg, 4000);
    
                                function showMsg() {
    
                                    jQuery('.error-msg').addClass('hidden');
    
                                    jQuery('.error-msg').removeClass('animated fadeIn fadeOut');
    
                                }
    
                                setTimeout(showMsg, 4500);
    
                            }
    
                            else {
    
                                jQuery('.subscribe').addClass('animated fadeOutDown');
    
                                jQuery('.thankyou').removeClass('hidden');
    
                                jQuery('.thankyou').addClass('animated fadeIn');
    
                            }
    
                        }
    
                    });
    
                }
    
            </script>
    
    • This reply was modified 7 years, 9 months ago by dennyspirit.
    • This reply was modified 7 years, 9 months ago by dennyspirit.
    • This reply was modified 7 years, 9 months ago by dennyspirit.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to enable subscriber name form’ is closed to new replies.