Formidable Forms and Caldera Forms in Geodirectory

This topic contains 8 replies, has 4 voices, and was last updated by  Alex Rollin 6 years, 2 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #427395

    Alex Howes
    Expired Member
    Post count: 175

    Hello,

    I want a form on my listing page which when submitted emails the listing owner.

    I’ve been using this (very useful!) documentation https://wpgeodirectory.com/formidable-forms-in-geodirectory-tabs/

    However I’d like to use Caldera Forms rather than Formidable, because it lets you upload documents.

    I’ve tried modifying the code by simply changing the shortcode and id values, but the email to the listing owner isn’t sending.

    I was wondering if you know what the problem might be? The form displays fine, and an email is sent to admin, just not to the listing owner.

    Thanks very much 🙂

    #427409

    Alex Howes
    Expired Member
    Post count: 175

    Update: I used the first part of the Formidable Forms code to add a tab and form to the listing details page. This works 🙂

    I’ve added some code as a snippet to try to send the email to the listing owner when the form is submitted. It works if, as a test, I put in any old email address:

    add_filter( ‘caldera_forms_mailer’, function( $mail, $data, $form ) {
    if( ‘CF5ad9d7’ == $form[ ‘ID’ ] ) {
    $mail[ ‘recipients’ ][] = ‘luke@skywalker.com’;
    }
    return $mail;
    }, 10, 3 );

    However when I try to obtain the listing owner’s email, it doesn’t work:

    add_filter( ‘caldera_forms_mailer’, function( $mail, $data, $form ) {
    if( ‘CF5ad9d7’ == $form[ ‘ID’ ] ) {
    $post_id = (isset($_POST[‘gd_place_id’]) && $_POST[‘gd_place_id’]) ? absint($_POST[‘gd_place_id’]) : ”;
    if ($post_id) {
    $place_email = geodir_get_post_meta($post_id, ‘geodir_email’);
    }
    if ($place_email) {
    $mail[ ‘recipients’ ][] = $place_email;
    }
    }
    return $mail;
    }, 10, 3 );

    Any help would be much appreciated 🙂

    #427412

    Alex Howes
    Expired Member
    Post count: 175

    Update: I think I need to add an extra (hidden) field to the form, containing the post ID. I’ve been looking for a way to do this for ages, but with no success 🙁

    #427427

    Paolo
    Site Admin
    Post count: 31206

    developers have been alerted.

    Thanks

    #427514

    Kiran
    Moderator
    Post count: 7069

    Hello There,

    Yes post id field required to get current post id, but form already has the field “_cf_cr_pst” to get post id.

    Use following snippet code to get current post id

    
    
    add_filter( 'caldera_forms_mailer', function( $mail, $data, $form ) {
    	if(  $form[ 'ID' ] == 'CF5ad9d76022ef2' ) {
    		$post_id = (isset($_POST['_cf_cr_pst']) && $_POST['_cf_cr_pst']) ? absint($_POST['_cf_cr_pst']) : '';
    		if ($post_id) {
              $place_email = geodir_get_post_meta($post_id, 'geodir_email');
            }
    		 if ($place_email) {
    			$mail[ 'recipients' ][] = $place_email;
    		 }
    	}
    	return $mail;
    }, 10, 3 );

    Kiran

    #427551

    Alex Howes
    Expired Member
    Post count: 175

    Great, thanks! 🙂 It’s all working now.

    Is it possible to add something to my code to make the new tab visible only to logged in users of a certain role?

    #427564

    Alex Rollin
    Moderator
    Post count: 27815

    GD does not offer features related to roles or role visibility, but we had a similar question and some discussion recently here: https://wpgeodirectory.com/support/topic/i-want-to-restrict-s2-member-access-to-a-specific-tab/#post-427397

    Take a look and let us know what you find.

    #427566

    Alex Howes
    Expired Member
    Post count: 175

    Cool, thanks for the link!

    In the end I decided to post the information as a widget instead, and use a third party plugin to only display it for certain user roles. I looked at using the code in the link but couldn’t find a capability that distinguished the user roles from each other, and thought it’d be more visible as a widget anyway 🙂

    #427569

    Alex Rollin
    Moderator
    Post count: 27815

    Sounds very reasonable.

    Glad you have something working for your site!

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

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

Open Support Ticket