• Resolved hcaandersen

    (@hcaandersen)


    Is there an inbuilt way to disable bookings for some users and enable bookings for others in Geodirectory?

    I’m PHP literate, so if there’s no inbuilt way then I’d appreciate any suggestions that involve PHP coding.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Paolo

    (@paoltaia)

    Hi,

    GeoDirectory currently does not provide booking features of any kind.

    You’d need to integrate some other plugin or custom build an entire booking system.

    Thanks,

    Thread Starter hcaandersen

    (@hcaandersen)

    Oh, sorry. That’s obviously coming from another plug-in.

    In that case, perhaps you can advise me on some integration. Basically I just want to get the value of a GD custom field from another plug-in. I’ve successfully used geodir_post_custom_fields() to get a list of GD’s custom fields and then found my own custom field in the list. When I pass it to geodir_get_cf_value(), however, I get an error saying that $gd_post doesn’t have a property, ID. I’ve put in some trace and $gd_post seems to be empty. Do I need to call another function to get $gd_post initialized?

    Plugin Author Paolo

    (@paoltaia)

    Hi @hcaandersen,

    sure we can help with that. I flagged your question for another team member who will answer ASAP.

    Thanks for your patience,

    Hello @hcaandersen,

    To get GD custom field value you need to have GD post ID. You can use one of following example to get GD custom field value.

    EXAMPLE 1: To get values for multiple fields.

    $post_id = 120; // Post ID.
    $geodir_post = geodir_get_post_info( $post_id );
    if ( ! empty( $geodir_post ) ) {
    	/**
    	 * USAGE: $value = $geodir_post->HTMLVAR_NAME;
    	 */
    	$city = $geodir_post->city;
    	$phone = $geodir_post->phone;
    	$email = $geodir_post->email;
    }

    EXAMPLE 2: To get value for specific field only.

    $post_id = 120; // Post ID.
    
    /**
     * USAGE: $value = geodir_get_post_meta( $post_id, 'HTMLVAR_NAME', true );
     */
    $city = geodir_get_post_meta( $post_id, 'city', true );
    $phone = geodir_get_post_meta( $post_id, 'phone', true );
    $email = geodir_get_post_meta( $post_id, 'email', true );

    Let us know.

    Best Regards,
    Kiran

    Thread Starter hcaandersen

    (@hcaandersen)

    Thank you so much for this! It got me where I wanted to go.

    For anyone else reading this, I modified n8kowald’s if-elseif-else-shortcode, by adding ‘allow_bookings’ to the array returned by get_allowed_callables() and adding the following function:

    function allow_bookings() {
        $post_id = get_the_ID();
        $geodir_post = geodir_get_post_info($post_id);
        if (!empty($geodir_post))
        	return $geodir_post->allow_bookings ? true : false;
        return false;
    }

    I added a Geodirectory custom field called ‘Allow bookings’ and was then able to use the shortcode like this:

    [if allow_bookings]
        [app_book]
    [else]
        This provider is not currently accepting online bookings.
    [/if]

    [app_book] comes from WP-BASE.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Disable bookings for some users’ is closed to new replies.