Formidable Forms and Caldera Forms in Geodirectory
This topic contains 8 replies, has 4 voices, and was last updated by Alex Rollin 6 years, 5 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
April 20, 2018 at 1:47 pm #427395
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 🙂
April 20, 2018 at 3:10 pm #427409Update: 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 🙂
April 20, 2018 at 3:47 pm #427412Update: 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 🙁
April 20, 2018 at 5:50 pm #427427developers have been alerted.
Thanks
April 21, 2018 at 6:48 pm #427514Hello 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
April 22, 2018 at 2:17 pm #427551Great, 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?
April 22, 2018 at 6:17 pm #427564GD 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.
April 22, 2018 at 7:21 pm #427566Cool, 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 🙂
April 22, 2018 at 7:55 pm #427569Sounds very reasonable.
Glad you have something working for your site!
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket