Male/Female Accept button…
-
Hi, I’m appreciating MailPoet. I didn’t know this plugin… after discover it, my life is changed π π
Jokes aside, I found “Male or Female” signup button, on some big fashion websites (like adidas): https://www.vogliosolodanza.it/immagine.png
I think that this solution is very useful to get an important data from the customer without increasing his clicks.
So, i can’t find the way to do it using MailPoet… but… i’m a software developer and I could developed this solution
But I am a developer and I have been able to develop this solution.
First – I added in backend 1 field with name custom_gender and Label: custom_gender_estesa and i edited submit button label: custom_malefemale_estesa_Iscriviti.Second – Basically, field gender will be hidden field (can you added hidden fields to form fields types?). Button, will be a double button. So, I’m using prefixes of labels (I cannot set name field) to know what field is and load custom templates.
File: lib/Form/Renderer.php
Edit: Code Added/Modified
Line: 56 – 64 ; 68 – 72/*Edit By Mariano*/ $custom_block = explode('_', $block['name']); if($custom_block[0] == "custom" || $custom_block[0] == "gender") $block['type'] = $custom_block[0]; $custom_submit = explode('_', $block['params']['label']); if($custom_submit[0] == "custom" && $custom_submit[1] == "malefemale") $block['type'] = "malefemale_submit"; /*foreach($block['params'] as $key=>$data) {$html .= $key." = ".$data."<br />";}*/ /* End Edit */ switch($block['type']) { /* Edit By Mariano */ case 'custom': case 'gender': $html .= Block\Custom::render($block); break; case 'malefemale_submit': $html .= Block\SubmitMaleFemale::render($block); break; /* End Edit */
Third – custom field templates:
File: /Form/Block/Custom.php<?php namespace MailPoet\Form\Block; if(!defined('ABSPATH')) exit; class Custom extends Base { static function render($block) { $type = 'hidden'; $html = ''; $html .= '<input type="'.$type.'" class="mailpoet_text '.$block['name'].'" '; $html .= 'name="data['.static::getFieldName($block).']" '; $html .= 'title="'.static::getFieldLabel($block).'" '; $html .= 'value="'.static::getFieldValue($block).'" '; $html .= static::getInputModifiers($block); $html .= '/>'; $html .= '<script>jQuery( document ).ready(function() { jQuery( "#mailpoet_form_1" ).on( "click", ".female-button-widget", function() { event.preventDefault(); jQuery( "input.'.$block['name'].'" ).val("F"); jQuery( "form.mailpoet_form.mailpoet_form_shortcode").submit(); }); jQuery( "#mailpoet_form_1" ).on( "click", ".male-button-widget", function() { event.preventDefault(); jQuery( "input.'.$block['name'].'" ).val("M"); jQuery( "form.mailpoet_form.mailpoet_form_shortcode").submit(); }); });</script>'; return $html; } }
File: /Form/Block/SubmitMaleFemale.php
<?php namespace MailPoet\Form\Block; if(!defined('ABSPATH')) exit; class SubmitMaleFemale extends Base { static function render($block) { $html = ''; $html .= '<p class="mailpoet_paragraph">'; $html .= '<button class="mailpoet_submit male-button-widget">Uomo</button>'; $html .= '<button class="mailpoet_submit female-button-widget">Donna</button>'; $html .= '</p>'; return $html; } }
.
This solution works fine, but i cannot make an override of this files. And in this step, You’re releasing many many updates (Thing good and fair). Can you implement something like that? Hidden fields, conditional buttons, fields name, or simply a Male/Female buttons?
Thank you, man.
- The topic ‘Male/Female Accept button…’ is closed to new replies.