Link to business, skip search part

This topic contains 9 replies, has 4 voices, and was last updated by  Paolo 7 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #403071

    anders
    Full Member
    Post count: 121

    Hi,

    I need help with removing the search functionality from “Link to business” when registering events.
    Instead, the selectlist here should simply be populated with whatever business the current user has registered as a gd_place -CPT.

    …every event needs to have a linked business and because there will almost always only be one gd_place -CPT business registered from each user, it seems illogical having to search for that every time a new event is registered.

    Thanks!

    #403194

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Anders,

    This would be a customisation, but its a relatively small task, you would need to remove this action

    add_action('geodir_event_business_fields_on_metabox', 'geodir_event_show_business_fields_html');

    And then add your own to replace it, basically copy and rename this function geodir_event_show_business_fields_html() to fit your needs.

    Thanks,

    Stiofan

    #403367

    anders
    Full Member
    Post count: 121

    Thank you Stiofan,

    Think I´m pretty close to what I need, modifying geodir_event_show_business_fields_html
    But could you please show me the correct way to place the function inside my child themes functions.php

    This is what I tried but didn’t work:

    
    
    function init_custom_link_to_business() {
    		remove_action('geodir_event_business_fields_on_metabox', 'geodir_event_show_business_fields_html');
    		add_action('geodir_event_business_fields_on_metabox', 'geodir_event_show_business_fields_html_custom');
    }
    add_action('init', 'init_custom_link_to_business');
    
    function geodir_event_show_business_fields_html_custom(){
        echo 'Modified version of geodir_event_show_business_fields_html comes here';
    }
    #403417

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    Please use the code snippets plugin. You can read more about it here:

    https://wpgeodirectory.com/docs/useful-plugins/#snippets

    Also, we have a section in the docs for other common code snippets that might help:

    https://wpgeodirectory.com/docs/common-code-snippets/

    Let us know how it works for you

    #403424

    anders
    Full Member
    Post count: 121

    Thank you Alex,

    I have already setup my child theme for Directory starter where I have my customizations working really nice (nothing complicated). Are you recommending I should switch to that plugin?

    …I have looked at the snippets page (and searched the forums) but haven´t found anything helping me with this.
    From Stiofans tip (and the forums) I have been able to modify the geodir_event_show_business_fields_html -function into what I need. Now I just would like to know the correct way to hook, remove, and replace the function, grateful for help with that

    Thanks!

    #403438

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    What you are requesting is a customization. Stiofan provided a hint in his response, to give you a start on it, or you can hire a developer to take it further.

    Code snippets is a simple tool to manage your custom functions, and doesn’t replace the value of a child theme.

    You can use the snippets plugin to add short snippets like that without the need to customize any other files.

    I have seen one other member discuss this functionality in the past. You can make a feature request here: https://wpgeodirectory.com/requests/

    Thanks!

    #403553

    anders
    Full Member
    Post count: 121

    Thank you Alex,

    I can see how Code snippets would be great with a custom child theme like Supreme.
    But I´m using a basic child theme for Directory starter that I believe serve the same purpose?
    Anyway I have the customization ready I just need help removing the parenttheme -function eodir_event_show_business_fields_html

    Thanks!

    #403564

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    as mentioned, that is a customization.

    Here is the documentation on the function that we can provide.

    https://wpgeodirectory.com/codex/codex/geodirectory-events_functions/geodir_event_show_business_fields_html/

    #403766

    anders
    Full Member
    Post count: 121

    Ok,

    I figured out how to achieve what I needed.

    This is what worked for me (for replacing geodir_event_show_business_fields_html -function)

    
    
    add_filter( 'template_include', 'geodir_event_template_loader_custom',1);
    function geodir_event_template_loader_custom($template) {
    		if(geodir_get_current_posttype() == 'gd_event'){			remove_action('geodir_before_detail_fields','geodir_event_show_business_fields_html',1);
    add_action('geodir_before_detail_fields','geodir_event_show_business_fields_html_custom',1);
    		}	
    		return $template;
    }
    function geodir_event_show_business_fields_html_custom() {
    		echo 'Modified version of the geodir_event_show_business_fields_html comes here';
    }

    Thanks!

    #403826

    Paolo
    Site Admin
    Post count: 31206

    That’s good news Andres, thanks for letting us know and for sharing! 🙂

Viewing 10 posts - 1 through 10 (of 10 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount