Email pop up form no longer working since update
-
Hi all, I had custom coding and a plugin carried on on one of my websites to allow members to be contacted by email, but instead of showing their email address, it had a pop up enquiry form. This have been working fine since it was set up last year, but now has an error message when trying to send the form since I updated buddypress.
The website is interfaithfoundation.org.
An example member profile with the ‘send email’ form link is http://interfaithfoundation.org/members/hyperbole1966/
I am no expert but am being told that there may be a problem with the email hook and the following code:
if ( $current_form->title == ‘Profile Form’)
{
$email = bp_get_profile_field_data( ‘field=Email’ );$components[‘recipient’] = cfh_get_email_from_link( $email );
}Any help would be very much appreciated as I really need to get it working again asap.
The complete code is as follows:
<?php
/*
Plugin Name: Contact Form Hooks
*/add_filter( ‘bp_get_the_profile_field_value’, ‘cfh_override_email_field’, 10, 3 );
add_filter( ‘wpcf7_mail_components’, ‘cfh_replace_mail_components’, 10, 3 );
add_action( ‘wp_enqueue_scripts’, ‘cfh_enqueue_style’ );
function cfh_enqueue_style()
{
$path = plugin_dir_url( __FILE__ );
wp_enqueue_style( ‘cfh-styles’, $path . ‘/style.css’ );
}function tribe_get_organizer_email_form( $output )
{
ob_start();
cfh_add_form_button( ‘Organizer Form’ );return ob_get_clean();
}function cfh_add_form_button( $title )
{
add_thickbox();
?>
<div id=”my-content-id” style=”display:none;”>
<p>
This is my hidden content! It will appear in ThickBox when the link is clicked.
</p>
</div>
<div id=”contact_form” style=”display:none;”>
<?php
echo do_shortcode(‘[contact-form-7 title=”‘.$title.'”]’);
?>
</div>
Send Email
<?php
}function cfh_get_email_from_link( $link )
{
$ary = array();if (preg_match(‘/.*mailto:(.*)”.*/’, $link, $ary ) )
{
return $ary[1];
} else {
return $link;
}}
function cfh_replace_mail_components( $components, $current_form, $form )
{
if ( $current_form->title == ‘Profile Form’){
$args = array(
‘field’ => ‘Email’,
‘user_id’ => ’22’
);$email = bp_get_profile_field_data( $args );
$components[‘recipient’] = $email ;
}if ( $current_form->title == ‘Organizer Form’)
{
$post_id = $components[‘recipient’];$email = tribe_get_organizer_email( $post_id );
$components[‘recipient’] = cfh_get_email_from_link( $email );
}return $components;
}function cfh_override_email_field( $value, $type, $id )
{
if ($type == ’email’ )
{
ob_start();// $recipient_email = get_email_from_link( $value );
cfh_add_form_button( ‘Profile Form’ );
// echo do_shortcode(‘[contact-form-7 title=”Profile Form”]’);
return ob_get_clean();
}
return $value;
}
?>
- You must be logged in to reply to this topic.