Support » Plugin: MailPoet - emails and newsletters in WordPress » Male/Female Accept button…

  • Resolved Il_maca

    (@il_maca)


    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.

    • This topic was modified 4 years, 10 months ago by Il_maca.
    • This topic was modified 4 years, 10 months ago by Il_maca.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Il_maca

    (@il_maca)

    I forget, my code is in develope mode. So, is unclear and not optimized. Sorry about that, but i don’t have much time to clear it, now. Maybe in few days, i post a reviewed code.

    Thank you.

    Plugin Support Bruna a11n

    (@bruberries)

    Hi @il_maca,

    You could click on “Add New Field” and add a Radion button with Male and Female options, for example. Is this what you’re looking for?

    You can read more about it here: http://beta.docs.mailpoet.com/article/140-how-to-create-a-subscription-form

    Thread Starter Il_maca

    (@il_maca)

    Hi Bruna,
    No, that isn’t what i’m looking.
    If you pay attention to image that i posted, you can see it is a bit different.
    I don’t want the simple radio button for the choose Male/Female. But 2 buttons to signin newsletter: one button for Males, one button for Females.
    Can you visit this url?

    https://www.adidas.it/on/demandware.store/Sites-adidas-IT-Site/it_IT/Newsletter-Subscribe

    It is the official adidas newsletter form. As you can see, they don’t have a radio button, but they have 2 buttons to signup in newsletter. If I’m male, i should click on male button confirm button. If i’m woman, i should press female confirm button.

    With your solution, i’ve a classic radio button and only 1 button for signin. So, the new solution is more practical and allows a truer graphics.

    I’m afraid we don’t have a built-in solution for that as you could see. Also, we don’t provide code customization support, unfortunately.

    Thread Starter Il_maca

    (@il_maca)

    Maybe, I didn’t explain well. I don’t want a code customization. My code works fine. I want suggest you to improve the form builder by implementing some basilar features… such as hidden fields, setting for the field’s name or the field’s id, custom javascript functions. Or implement by yourself a solution like that i proposed, considering that is a new way to get the “male/female” field.

    So, we says in this case:
    Check’azz vu leet, fash’it!
    It means: “It’s just a suggestion!”

    thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Male/Female Accept button…’ is closed to new replies.