WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Link on email validator

[Resolved] Link on email validator

  • candell
    Participant

    @candell

    Giving a form field a ‘URLValidator’ puts the field a link on the page, however ‘EmailValidator’ doesn’t do that.

    I tried adding this to \api\api.php but didn’t work. Can anyone suggest anything for this?

    Here’s what I did code block starting line 187

    case 'meta':
                default:
                    $value = wpbdp_get_listing_field_value($listing, $field);
    
                    if ($value) {
                        if (in_array($field->type, array('multiselect', 'checkbox'))) {
                            return esc_attr(str_replace("\t", ', ', $value));
                        } elseif ($field->type == 'textarea') {
                            return wpautop(wp_kses($value, array()), true);
                        } elseif ($field->type == 'social-twitter') {
                            return _wpbdp_display_twitter_button($value, array('lang' => substr(get_bloginfo('language'), 0, 2)) );
                        } elseif ($field->type == 'social-linkedin') {
                            return _wpbdp_display_linkedin_button($value);
                        } elseif ($field->type == 'social-facebook') {
                            return _wpbdp_display_facebook_button($value);
    					} elseif ($field->type == 'EmailValidator') {
                            return "<a href=mailto:".$value.">".$value."</a>";
                        } else {
                            if ($field->validator == 'URLValidator') {
                                if (is_array($value)) {
                                    $value_url = $value[0];
                                    $value_text = !empty($value[1]) ? $value[1] : $value[0];
                                } else {
                                    $value_url = $value;
                                    $value_text = $value;
                                }
    
                                if (!$value_url)
                                    return '';
    
                                return sprintf('<a href="%s" target="%s" title="%s">%s</a>',
                                               esc_url($value_url),
                                               isset($field->field_data['open_in_new_window']) && $field->field_data['open_in_new_window'] ? '_blank' : '_self',
                                               esc_attr($value_text),
                                               esc_attr($value_text));
                            }
    
                            return wp_kses($value, array());
                        }
                    }

    My new part is the if EmailValidator part. Thanks

    http://wordpress.org/extend/plugins/business-directory-plugin/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author businessdirectoryplugin
    Participant

    @businessdirectoryplugin

    Hi candell,

    Yes, the email validator isn’t supposed to put a link out there. The link makes it easy to harvest the address, as spambots look for “mailto:” and then scrape the address. It’s not as obvious with a plain email field.

    We’ll look into this as a future enhancement though. Thanks for the feedback.

    candell
    Participant

    @candell

    If anyone is interested this is now working for me, I was checking $field->type when I should have been checking $field->validator

    All sorted now, i know it’s bad but what the client wants…

    Plugin Author businessdirectoryplugin
    Participant

    @businessdirectoryplugin

    Sometimes that’s the only solution that matters. 🙂

    saritlotem
    Member

    @saritlotem

    Hi candell, have the same problem, can you explain exactly what you did.
    did you change the html?
    Thanks

    candell
    Participant

    @candell

    Hi saritlotem

    It means editing a core file of the plugin so if you upgrade, you will have to make this change again.

    Just find the code block in my original post (I mention the file and line number) and replace with the above code. You need to change

    } elseif ($field->type == 'EmailValidator') {

    to

    } elseif ($field->validator == 'EmailValidator') {

    job done

    sarah.avadhoot
    Member

    @sarahavadhoot

    Hi candell,
    I am trying to do the exact same thing as well :-).
    I am using version Version 3.0.2 of the Business Directory Plugin. But, I cannot find the code snitppets that you have mentioned in your code. Which version are you using? Can you possibly help me out please?

    Many thanks,
    Sarah

    candell
    Participant

    @candell

    Hi Sarah

    I am using 2.something, I made so many changes to make the plugin work as we needed it to that I can’t upgrade.

    Sorry i can’t help with v3 if they have changed those functions, but I guess if you search all pages for similar code i.e.

    $field->validator

    you should be able to find a solution

    sarah.avadhoot
    Member

    @sarahavadhoot

    hi candell,
    Thank you so much for your quick reply!

    Many thanks,
    Sarah

    candell
    Participant

    @candell

    No problem, I am very busy at the moment but if you haven’t figured it out by the end of next week, reply and I should be able to download the latest version and take a quick look (the plugin author may have helped you by then too)

    sarah.avadhoot
    Member

    @sarahavadhoot

    Thanks heaps for the offer to help me out if I havent been able to do it…I may take you up on it 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Link on email validator’ is closed to new replies.