• Resolved zimbo000

    (@zimbo000)


    I know the plugin does not support the adding of hyperlinks to the email address in a listing – and fully understand why you don’t do it – but I have a client who wants that functionality added.

    I know this will require a plugin code hack but I have searched all the documentation and done loads of searches of the source code to try and find exactly where div class="field-value wpbdp-field-email wpbdp-field-meta"> for a listing is “created” – but I cannot find it anywhere.

    Please can you tell me the code module and – preferably – the line numbers in the code where the email address gets displayed. Hopefully I can figure it out from there. Thanks in advance.

    https://www.ads-software.com/plugins/business-directory-plugin/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Hi zimbo000,

    You can use our customization guide to see what files control which pieces of functionality in the application here: https://businessdirectoryplugin.com/docs/customization-guide/

    Using that, you can find the correct places to modify the code and make the kinds of changes you’re looking for.

    Thread Starter zimbo000

    (@zimbo000)

    “I have searched all the documentation and done loads of searches of the source code … but I cannot find it anywhere.”

    I have found templates-listings.php but cannot work out or find the code section that displays the email link. Please can you tell me which file it is in and the line numbers.

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    When you say “displays the email link” there are two possible ways to interpret that. Perhaps that’s the confusion here.

    Do you mean:
    1) A hyperlink that goes out in one of the emails?
    2) A link to an email address that displays in the listings?

    The former requires template editing. The templates are found under templates/email in the plugin source code.

    The latter can be changed using a setting, which we don’t recommend using because it allows spam bots to harvest emails from your site, increasing spam for your users. That setting is found under Directory Admin->Manage Options, Email tab “Display email address fields publicly?”.

    Is that what you need? If not, can you explain in more detail what you’re looking for? It’s hard to pinpoint a file if I’m not sure what functionality you want to change.

    Thread Starter zimbo000

    (@zimbo000)

    The second option, but I have already turned on Directory Admin->Manage Options, Email tab “Display email address fields publicly”.

    What the plugin does not do is set a hyperlink on the email text so a user can click on it and then open their email client, i.e. the HTML is <a href="mailto:[email protected]">[email protected]</a>.

    I know all about spam bots & harvesting but my client insists they want the email in a listing hyperlinked.

    Searching through past support queries this request has come up before and you have provided guidance to folks on how to change the code to make this work. However these answers are all over 2 years old and your code has significantly changed since then and none of the solutions are valid anymore, e.g. https://www.ads-software.com/support/topic/link-on-email-validator?replies=11

    Can you please tell me where the code section is that displays an email link so I can edit it to add the <a href… into it. I’ve searched all over but cannot find it.

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Which field do you want to display this in?

    We support HTML enabling on the Long Description field, and if you turn that on, you can go nuts with that on that field.

    Basically, it’s the same code but you’d have to put it in another field–that particular setting has a unique value to it, so you could back-trace it.

    I can ask my developer, but he’s backed up on a number of support requests this week desperately trying to catch up to me posting them. ?? It will be a bit before I can get his input on that.

    Thread Starter zimbo000

    (@zimbo000)

    I want to hyperlink the text associated with the ‘Email’ label shown in View All Listings plus the individual single View.

    Both are set by a HTML section starting
    <div class="field-value wpbdp-field-email wpbdp-field-meta"> but I cannot work out how or where that <div> is created. I’ve traced through templates-listings.php but came to a dead end.

    My client is keen to launch the plugin on its website as soon as possible (we’ve been testing and customising it so far) and they will need to purchase a few premium plugins such as PayPal and Google Maps to provide the full functionality needed – but until this issue is fixed they are holding back. Hopefully you can ask your developer for how to do this soon… ??

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    OK, I got an answer back more quickly than I expected! Here you are:

    The following code should do the trick for all fields that have an e-mail validator:

    <?php
    function add_link_to_emails( $value, $post_id, $field ) {
        if ( ! $field->has_validator( 'email' ) )
            return $value;
    
        return '<a href="mailto:' . $value . '">' . $value . '</a>';
    }
    add_filter( 'wpbdp_form_field_html_value', 'add_link_to_emails', 10, 3 );

    It can be added anywhere in the code, to the theme or as an additional plugin.

    You must add an email validator to the field for this to work: when adding or editing a field you can add a validator to it under Directory Admin->Manage Form Fields. We provide several validators (integer number, decimal number, etc.) including one specifically designed for e-mails. Our default e-mail field has such a validator set. Your field will need the same.

    Without that, it’s very difficult to differentiate between regular fields and e-mail fields and that’s what makes this work.

    Thread Starter zimbo000

    (@zimbo000)

    Many thanks, this works perfectly!!!

    The site has a child theme and I added the code into the child’s functions.php file so that any plugin or theme updates won’t over-write it. Thanks again.

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Glad I could help!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to add email hyperlinks’ is closed to new replies.