Hide Fields From Logged Out Users

This topic contains 2 replies, has 3 voices, and was last updated by  Kiran 2 years, 7 months ago.

  • Author
  • #438867

    Full Member
    Post count: 23

    Hi! I’m trying to see if I can use your plugin instead of AWPCP – there are a few things which are MUCH better in yours!

    The website content will be mostly user-submitted listings. I need some fields to be visible only to logged in members, and completely hidden from unregistered visitors/bots/etc. For example, could contact info fields such as email for listings be visible only to registered members? Is there any easy way to do this? Also, since I just added almost a dozen of your plugins, I’d like to avoid fiddling with ANOTHER separate plugin to hide things…

    PS: I wonder if I’m missing anything obvious in the settings… I don’t want this to be admin-only, since all subscribers should see it.



    Post count: 29970

    You will need a membership plugin to achieve what you describe.
    I doubt that there is any simple code that would hide fields completely for other than logged in users, but I will get a developer to have a look at your question too, just in case.


    Post count: 7069

    Hello Luca,

    Add following code snippet to hide fields from guest users.

    function _gd_custom_setup_guest_hide_field() {
    	if ( is_user_logged_in() ) {
    	$fields = array();
    	$fields[] = 'geodir_contact';
    	$fields[] = 'geodir_email';
    	if ( ! empty( $fields ) ) {
    		foreach ( $fields as $field ) {
    			add_filter( 'geodir_show_' . $field, '_gd_custom_guest_hide_field', 10, 2 );
    add_filter( 'init', '_gd_custom_setup_guest_hide_field', 10 );
    function _gd_custom_guest_hide_field( $html, $params ) {
    	if ( ! is_user_logged_in() ) {
    		$html = '';
    	return $html;

    Currently it is working with phone & email fields but you can add more fields at “// ADD MORE FIELDS HERE”.


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

The topic ‘Hide Fields From Logged Out Users’ is closed to new replies, this may be for inactivity, please open a new topic if you have a similar question.