WordPress.org

Ready to get started?Download WordPress

Forums

Business Directory Plugin
[resolved] Link on email validator (11 posts)

  1. candell
    Member
    Posted 1 year ago #

    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/

  2. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. candell
    Member
    Posted 1 year ago #

    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...

  4. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    Sometimes that's the only solution that matters. :)

  5. saritlotem
    Member
    Posted 1 year ago #

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

  6. candell
    Member
    Posted 1 year ago #

    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

  7. sarah.avadhoot
    Member
    Posted 1 year ago #

    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

  8. candell
    Member
    Posted 1 year ago #

    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

  9. sarah.avadhoot
    Member
    Posted 1 year ago #

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

    Many thanks,
    Sarah

  10. candell
    Member
    Posted 1 year ago #

    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)

  11. sarah.avadhoot
    Member
    Posted 1 year ago #

    Thanks heaps for the offer to help me out if I havent been able to do it...I may take you up on it :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.