Insert [shortcode] of another application

This topic contains 34 replies, has 4 voices, and was last updated by  Kor 7 years, 4 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #308696

    Patrick BAISSAT
    Expired Member
    Post count: 65

    Hello
    To manage private access I use the extension: Private Content. This extension works with shortcodes that you insert before and after the text you want to protect.
    Example:
    [Private role = “contributor”]
    Security Register
    [/ Private]

    I can put these shortcodes in the My Profile tab, corresponding to the description of the place, and it is OK.
    But, is it possible to put these shortcodes in other tab like fields: Text, HTML, text area, custom fields?
    Thank you
    Patrick

    #308848

    Kor
    Moderator
    Post count: 16516

    Hi Patrick,

    You can insert 3rd party shortcodes into the custom fields, but you’ll need to first insert the custom code below into your functions.php file.

    
    
    function my_enable_shortcodes_in_cf($html,$location,$cf){
      
        // this line will enable it for all text inputs
        $html = do_shortcode( $html );
        return $html;
    }
    add_filter('geodir_custom_field_output_text','my_enable_shortcodes_in_cf',15,3);

    Thanks!

    #309535

    Patrick BAISSAT
    Expired Member
    Post count: 65

    Thank you,
    I modified the file function.php with your script.
    I created 2 fields with the ACF extension of Elliot CONDON, one with a file and the other with a text box.
    But I do not see it in Geodirectory -> Place settings

    Best regards,
    Patrick

    #309841

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    ACF is not compatible with GeoDirectory. You need to use GD’s own field…

    Thanks

    #309925

    Patrick BAISSAT
    Expired Member
    Post count: 65

    Thank you Paolo,

    but in Place Settings, i can create some custom fields.

    And if ACF is not compatible, another extension ? or an add-on ?

    Thanks for your help.

    Patrick

    #310110

    Paolo
    Site Admin
    Post count: 31206

    You don’t need an extension or add-on to create custom fields. You can do it from place settings. What is not clear about it?

    Let us know,

    Thanks

    #310604

    Patrick BAISSAT
    Expired Member
    Post count: 65

    Not too much, what I want exactly is a tab on the page of places that is visible only by login.
    Example:
    I want to create a tab to put a file or text that will only be visible to administrators. In the first tab that corresponds to the description, it works, but I would like several, different: date, file, text, etc. .
    I use the Private Content extension with tags like this: [private role = “administrator”] this text is visible only with the administrator role [/ private]
    With ACF the advantage is that the field already integrated this functionality, but it is not compatible. . . Then this extension is abandoned.
    I would be you I would create an add-on to privatize certain fields according to the login.
    But in the meantime, would you have a solution for me?
    In addition I have inserted in the file funtions.php the piece of code of Kor Chung, but I do not see any difference.
    thank you very much

    #310977

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Patrick,

    The code KC gave you would only make shortcodes work inside things like a textarea input but not for most others.

    do you just want some example code of how to hide a tab for everyone except admins?

    Thanks,

    Stiofan

    #311081

    Patrick BAISSAT
    Expired Member
    Post count: 65
    This reply has been marked as private.
    #314326

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Patrick,

    OK when adding a new field, you can make it “admin use only” this will mean only admins will be able to see the field on the add listing form (if you want that functionality)

    Then you can use this filter for the tabs
    geodir_tab_show_{$html_var}
    so if the tab is called geodir_facebook

    we would add:

    
    
    add_filter('geodir_detail_page_tab_is_display','_my_hide_tabs_to_non_admin',10,2);
    function _my_hide_tabs_to_non_admin($val,$htmlvar_name){
    
    	//echo '###'.$htmlvar_name; // uncomment to get var names
    	if($htmlvar_name=='geodir_facebook' && !is_super_admin()){$val = false;}
    	if($htmlvar_name=='geodir_someother' && !is_super_admin()){$val = false;}
    	return $val;
    }

    Thanks,

    Stiofan

    #314525

    Patrick BAISSAT
    Expired Member
    Post count: 65

    Thank you for your help.
    If I understood correctly, I create a field, example date_close in DATE format.
    The script you gave me is written like this:

    
    
    add_filter('geodir_detail_page_tab_is_display','_my_hide_tabs_to_non_admin',10,2);
    function _my_hide_tabs_to_non_admin($val,$htmlvar_name){
    
    	//echo '###'.$htmlvar_name; // uncomment to get var names
    	if($htmlvar_name=='geodir_date_close' && !is_super_admin()){$val = false;}
    	if($htmlvar_name=='geodir_someother' && !is_super_admin()){$val = false;}
    	return $val;
    }

    I have changed your field geodir_facebook, by geodir_date_close.
    I insert this in function.php in theme child (see file in the footer of this message), and is ko.
    the new field is in back-office but not in front office, Admin or not.
    I think there’s one thing I did not understand. Is it in fucntion.php that I have to insert this script?
    I thank you again for helping me.
    Patrick
    FUNCTIONS.PHP :

    
    
    <?php
    /**
    **  activation theme
    **/
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    
    }
    
    function my_enable_shortcodes_in_cf($html,$location,$cf){
      
        // this line will enable it for all text inputs
        $html = do_shortcode( $html );
        return $html;
    }
    add_filter('geodir_custom_field_output_text','my_enable_shortcodes_in_cf',15,3);
    
    add_filter('geodir_detail_page_tab_is_display','_my_hide_tabs_to_non_admin',10,2);
    function _my_hide_tabs_to_non_admin($val,$htmlvar_name){
    
    	//echo '###'.$htmlvar_name; // uncomment to get var names
    	if($htmlvar_name=='geodir_fin_bail' && !is_super_admin()){$val = false;}
    	if($htmlvar_name=='geodir_someother' && !is_super_admin()){$val = false;}
    	return $val;
    }
    ?>
    #314529

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    The code i gave was for specifically hiding a tab not an individual item.
    this is the one for individuals:
    “geodir_custom_field_output_{$filed_type}”

    
    
    add_filter("geodir_custom_field_output_textarea",'_my_hide_field_from_admin',10,3);
    add_filter("geodir_custom_field_output_datepicker",'_my_hide_field_from_admin',10,3);
    add_filter("geodir_custom_field_output_url",'_my_hide_field_from_admin',10,3);
    function _my_hide_field_from_admin($html,$fields_location,$type){
    
    	if(isset($type['is_admin']) && $type['is_admin'] && !is_super_admin()){
    		$html = '';
    	}
    	return $html;
    }

    Stiofan

    #314560

    Patrick BAISSAT
    Expired Member
    Post count: 65

    YES ! ! YES ! ! YES ! ! !
    It’s working correctly 🙂 🙂 🙂
    My field date_close appear if i am admin, and not for the other users.

    have a nice day, week, month, year and century
    Patrick

    #314577

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Haha, glad its working for you 🙂
    Feel free to leave us a review to help us grow: https://wordpress.org/support/plugin/geodirectory/reviews/?rate=5#new-post

    Thanks,

    Stiofan

    #314601

    Patrick BAISSAT
    Expired Member
    Post count: 65

    Ok, i write a review 5 stars.

    If you can, I advise you to develop a simple addon, to manage the display of tabs according to the login.
    Only on the 5 profiles that are original in WP, which allows to display or not the content of the field in the front office. A box to be added when the field is inserted.
    for example:
    Do you want to manage rights in this field: YES / NO
    To whom do you want to give the display rights: admin, contributor, etc. ..
    If you intend to develop this kind of addon tell me I could test it to you.

    Best regards 🙂
    Patrick

Viewing 15 posts - 1 through 15 (of 35 total)

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

Open Support Ticket