Displaying expiration date to listing owner only

This topic contains 4 replies, has 3 voices, and was last updated by  laurence anthony 4 years, 3 months ago.

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

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #525482

    laurence anthony
    Expired Member
    Post count: 293

    Hi,
    I’m trying to hide the expiration date to everyone except the listing owner on both the listings page and the details page.

    I’ve tried shortcode for output location and the shortcode generator. I’ve also tried GD post meta widget. But no luck.
    [gd_output_location location=”detail”]
    [gd_post_meta key=”expire_date” location=”listing”]

    Currently, everyone can see expiration date.

    thanks
    larry

    What am I missing?

    #525494

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    The Expire Date field should be set to “Admin only” in the field options, and my apologies for any confusion about that.

    If you visit the field in the custom fields settings, and open advanced, set “Admin Only” and remove and values stored in “Show in extra output locations” it will not show to anyone.

    Currently the field value will only show to the listing owner in the form of a reminder to upgrade. There is no way to show it on the frontend, with GD Post Meta, or as a badge, that will only show it to the listing owner or admin.

    I will ask the developers if there is a workaround.

    #525497

    laurence anthony
    Expired Member
    Post count: 293

    ok thanks for clarification, Alex.

    #525946

    Kiran
    Moderator
    Post count: 7069

    Hi laurence,

    Try following PHP snippet to show expire date to post owner only.

    
    
    /**
     * Show expire date to post owner only.
     */
    function gd_snippet_200116_show_field_to_owner_only( $html, $location, $cf, $p = '',$output = '' ) {
    	global $gd_post;
    
    	if ( empty( $gd_post ) || ! $html ) {
    		return $html;
    	}
    
    	if ( ! is_array( $cf ) && $cf != '' ) {
    		$cf = geodir_get_field_infoby( 'htmlvar_name', $cf, $gd_post->post_type );
    
    		if ( empty( $cf ) ) {
    			return $html;
    		}
    	}
    
    	$field = 'expire_date';
    	$htmlvar_name = $cf['htmlvar_name'];
    
    	if ( $field == $htmlvar_name && ! empty( $gd_post->{$htmlvar_name} ) ) {
    		if ( ! ( get_current_user_id() && geodir_listing_belong_to_current_user( $gd_post->ID ) ) ) {
    			$html = '';
    		}
    	}
    
    	return $html;
    }
    add_action( 'geodir_custom_field_output_datepicker', 'gd_snippet_200116_show_field_to_owner_only', 9999, 4 );

    Kiran

    #526098

    laurence anthony
    Expired Member
    Post count: 293

    Worked great, Kiran. Thank you!

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

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

Open Support Ticket