Forum Replies Created
-
I have faith in the community that someone wants to make some money to help me show an xprofile field inside appointments+ email notification template.
Who wants $$$$$
so none of these work
$wpdb->get_var(“SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 206 AND user_id = $r->ID”);
$wpdb->get_col(“SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 206 AND user_id = $r->ID”);
$wpdb->get_results(“SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 206 AND user_id = $r->ID”);
I think something is still missing
help please anyone?
any chance you can skype and I can just show the files
So here’s what I have done.
if I set it like this
$User_phone = get_userdata($r->user); $Worker_phone = get_userdata($r->worker); $args = array( 'user' => $r->name, 'customer_username'=>$customerUser->user_login, 'artist_username'=>$artistUser->user_login, 'service' => $appointments->get_service_name( $r->service ), 'worker' => appointments_get_worker_name( $r->worker ), 'datetime' => $r->start, 'price' => $r->price, 'deposit' => $appointments->get_deposit( $r->price ), 'phone' => $r->phone, 'user_phone' => $User_phone->user_login, 'worker_phone' => $Worker_phone->user_login, 'note' => $r->note, 'address' => $address, 'email' => $email, 'city' => $r->city, 'number_of_guest'=>$r->number_of_guest, 'travel_type'=>$travel_type, 'ID'=>$r->ID );
and I set USER_PHONE and WORKER_PHONE in my email templates is shows the correct usernames or worker name of each user or worker in the emails so the shortcode setup works it’s just the data on the right .
so It would seem what need to be changed is this
'user_phone' => $User_phone->user_login, 'worker_phone' => $Worker_phone->user_login,
but if I change to
$User_phone->user_login, to $wpdb->get_col(“SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 7 AND user_id = $r->ID”),
you were missing the closing ” and I can’t put ; it has to be , at the end
it shows no errors just shows blank on the email.
here is the entire confirmation email template
<?php class Appointments_Notifications_Confirmation extends Appointments_Notification { /** * Send confirmation email to customer, admin and worker * * @param integer $app_id Appointment ID * * @return bool True if emails were sent */ public function send( $app_id ) { $appointments = appointments(); $app = appointments_get_appointment( $app_id ); if ( ! $app ) { return false; } $options = appointments_get_options(); $send_confirmation = 'yes' === $options["send_confirmation"]; $send_confirmation = apply_filters( 'appointments_send_confirmation', $send_confirmation, $app_id ); if ( ! $send_confirmation ) { return false; } $sent_to = array(); $customer_email = $app->get_customer_email(); $result = $this->customer( $app_id, $customer_email ); if ( $result ) { $sent_to[] = $customer_email; $admin_email = $appointments->get_admin_email(); if ( ! in_array( $admin_email, $sent_to ) && $this->admin( $app_id, $admin_email ) ) { $sent_to[] = $admin_email; } $worker_email = $appointments->get_worker_email( $app->worker ); if ( ! in_array( $worker_email, $sent_to ) ) { $this->admin( $app_id, $worker_email ); } return true; } return $result; } /** * Sends a confirmation email to the customer * * @param int $app_id Appointment ID * @param string $email Email to send to * * @return bool True if the email has been sent */ public function customer( $app_id, $email ) { $appointments = appointments(); $r = appointments_get_appointment( $app_id ); if ( ! $r ) { return false; } if ( ! is_email( $email ) ) { $this->manager->log( sprintf( __( 'Unable to notify the client about the appointment ID:%s confirmation, stopping.', 'appointments' ), $app_id ) ); return false; } $template = $this->get_customer_template( $app_id, $email ); if ( ! $template ) { return false; } $attachments = apply_filters( 'app_confirmation_email_attachments', '', $app_id ); $mail_result = wp_mail( $email, $template['subject'], $template['body'], $appointments->message_headers(), $attachments ); if ( ! $mail_result ) { return false; } $this->manager->log( sprintf( __('Confirmation message sent to %s for appointment ID:%s','appointments'), $r->email, $app_id ) ); do_action( 'app_confirmation_sent', $template['body'], $r, $app_id, $email ); return true; } /** * Send a confirmation email to admin * * @param $app_id * @param $admin_email * * @return bool */ public function admin( $app_id, $admin_email ) { $appointments = appointments(); $r = appointments_get_appointment( $app_id ); if ( ! $r ) { return false; } $disable = apply_filters( 'app_confirmation_disable_admin', false, $r, $app_id, $admin_email ); if ( $disable ) { return true; } if ( ! is_email( $admin_email ) ) { return false; } $template = $this->get_admin_template( $app_id ); if ( ! $template ) { return false; } $result = wp_mail( $admin_email, $template['subject'], $template['body'], $appointments->message_headers() ); if ( $result ) { do_action( 'appointments_confirmation_admin_sent', $admin_email, $app_id, $template['body'], $template['subject'] ); } return $result; } public function get_admin_template( $app_id ) { global $wpdb; $appointments = appointments(); $r = appointments_get_appointment( $app_id ); if ( ! $r ) { return false; } $customer_email = $r->get_customer_email(); if ( ! $customer_email ) { return false; } /*$provider_add_text = sprintf( __('A new appointment has been made on %s. Below please find a copy of what has been sent to your client:', 'appointments'), get_option( 'blogname' ) ); $provider_add_text .= "\n\n\n"; $subject = __('New Appointment','appointments');*/ /*Added by */ $options = appointments_get_options(); $subject = $options["confirmation_subject_artist"]; $provider_add_text = $options['confirmation_message_artist']; if($r->travel_type==2){ $address=$r->address; $travel_type="Photographer Travel to Me"; } else { $sql = "SELECT * FROM <code>wppl_friends_locator</code> where member_id=".$r->worker; $squad=$wpdb->get_results( $sql ); if($squad){ $address=$squad[0]->formatted_address; } else{ $address=""; } $travel_type="Travel to Photographer"; } $customerUser = get_userdata($r->user); $artistUser = get_userdata($r->worker); $User_phone = get_userdata($r->user); $Worker_phone = get_userdata($r->worker); $args = array( 'user' => $r->name, 'customer_username'=>$customerUser->user_login, 'artist_username'=>$artistUser->user_login, 'service' => $appointments->get_service_name( $r->service ), 'worker' => appointments_get_worker_name( $r->worker ), 'datetime' => $r->start, 'price' => $r->price, 'deposit' => $appointments->get_deposit( $r->price ), 'phone' => $r->phone, 'user_phone' => $User_phone->user_login, 'worker_phone' => $Worker_phone->user_login, 'note' => $r->note, 'address' => $address, 'email' => $email, 'city' => $r->city, 'number_of_guest'=>$r->number_of_guest, 'travel_type'=>$travel_type, 'ID'=>$r->ID ); $provider_add_text = $this->replace_placeholders( $provider_add_text, $args, 'confirmation-body', $r ); /*end Added by */ $body = $this->get_customer_template( $app_id, $customer_email ); return array( 'subject' => $subject, 'body' => $provider_add_text ); } public function get_customer_template( $app_id, $email ) { global $wpdb; $appointments = appointments(); $r = appointments_get_appointment( $app_id ); if ( ! $r ) { return false; } $options = appointments_get_options(); $body = $options['confirmation_message_customer']; if($r->travel_type==2){ $address=$r->address; $travel_type="Photographer Travel to Me"; } else { $sql = "SELECT * FROM <code>wppl_friends_locator</code> where member_id=".$r->worker; $squad=$wpdb->get_results( $sql ); if($squad){ $address=$squad[0]->formatted_address; } else{ $address=""; } $travel_type="Travel to Photographer"; } $customerUser = get_userdata($r->user); $artistUser = get_userdata($r->worker); $Worker_phone = get_userdata($r->worker); $args = array( 'user' => $r->name, 'customer_username'=>$customerUser->user_login, 'artist_username'=>$artistUser->user_login, 'service' => $appointments->get_service_name( $r->service ), 'worker' => appointments_get_worker_name( $r->worker ), 'datetime' => $r->start, 'price' => $r->price, 'deposit' => $appointments->get_deposit( $r->price ), 'phone' => $r->phone, 'worker_phone' => $Worker_phone->user_login, 'note' => $r->note, 'address' => $address, 'email' => $email, 'city' => $r->city, 'number_of_guest'=>$r->number_of_guest, 'travel_type'=>$travel_type, 'ID'=>$r->ID ); $body = $this->replace_placeholders( $body, $args, 'confirmation-body', $r ); $body = $appointments->add_cancel_link( $body, $app_id ); $body = apply_filters( 'app_confirmation_message', $body, $r, $app_id ); $subject = $options["confirmation_subject_customer"]; $subject = $this->replace_placeholders( $subject, $args, 'confirmation-subject', $r ); return array( 'subject' => $subject, 'body' => $body ); } }
thank you again
I believe the user is is already pulled because we show username, links to profile pages in email template already.
There is a notification file but I already called USER_PHONE AND WORKER_PHONE. Correctly into this file.
$replacement = array( '/\bSITE_NAME\b/U' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), '/\bCLIENT\b/U' => $args['user'], '/\bCUSTOMER_USERNAME\b/U'=> $args['customer_username'], '/\bARTIST_USERNAME\b/U' => $args['artist_username'], '/\bSERVICE_PROVIDER\b/U' => $args['worker'], '/\bSERVICE\b/U' => preg_replace( '/\$(\d)/', '\\\$$1', $args['service'] ), '/\bDATE_TIME\b/U' => mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $args['datetime'] ), '/\bORDER_ID\b/U' => $args['ID'], '/\bTRAVEL_TYPE\b/U' => $args['travel_type'], '/\bUSER_PHONE\b/U' => $args['user_phone'], '/\bWORKER_PHONE\b/U' => $args['worker_phone'],
This basically sets the SHORTCODE for use in admin notification email template section.
I think I also need to add some code to the functions.php file of my theme. I see some other coding in functions.php from my past developer but it may not be related to the notification parts.
$profile_name=xprofile_get_field_data( 'Profile Name' , $user_id ); if($profile_name!=""){ global $wpdb; $query="select * from {$wpdb->prefix}bp_xprofile_data"; $phone=$wpdb->get_results($query); if(count($phone)>0){ $arr=array(); foreach($phone as $service){ $arr[]= $service->ID; $arr2=array( 'service_id' => $service->ID, 'provider_id' => $user_id, 'additional_price' => 0 ); $wpdb->insert( "{$wpdb->prefix}app_service_additional_price", $arr2); }
I don’t understand how we can change this to bp_xprofile_data all I need to call at this point is the phone data id 206 and 7 the field title is Phone.
This is what I have in my confirmation template but not working error line user phone and worker phone
$User_phone = get_userdata($r->phoneuser); $Worker_phone = get_userdata($r->phoneworker); $args = array( 'user' => $r->name, 'customer_username'=>$customerUser->user_login, 'artist_username'=>$artistUser->user_login, 'service' => $appointments->get_service_name( $r->service ), 'worker' => appointments_get_worker_name( $r->worker ), 'datetime' => $r->start, 'price' => $r->price, 'deposit' => $appointments->get_deposit( $r->price ), 'phone' => $r->phone, 'user_phone' => $User_phone->user_login, 'worker_phone' => $Worker_phone->user_login, 'phoneuser' => $wpdb->get_col("SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 206 AND user_id = $user_id"); 'phoneworker' => $wpdb->get_col("SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 7 AND user_id = $user_id"); 'note' => $r->note, 'address' => $address, 'email' => $email, 'city' => $r->city, 'number_of_guest'=>$r->number_of_guest, 'travel_type'=>$travel_type, 'ID'=>$r->ID );
I also tried this which did not show errors but just didn’t work
$User_phone = $wpdb->get_col("SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 206 AND user_id = $user_id"); $Worker_phone = $wpdb->get_col("SELECT value FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 7 AND user_id = $user_id"); $args = array( 'user' => $r->name, 'customer_username'=>$customerUser->user_login, 'artist_username'=>$artistUser->user_login, 'service' => $appointments->get_service_name( $r->service ), 'worker' => appointments_get_worker_name( $r->worker ), 'datetime' => $r->start, 'price' => $r->price, 'deposit' => $appointments->get_deposit( $r->price ), 'phone' => $r->phone, 'user_phone' => $User_phone->user_login, 'worker_phone' => $Worker_phone->user_login, 'note' => $r->note, 'address' => $address, 'email' => $email, 'city' => $r->city, 'number_of_guest'=>$r->number_of_guest, 'travel_type'=>$travel_type, 'ID'=>$r->ID );
they don’t help they are so slow. The only requirements are calling the xprofile fields into a template file
anybody have any ideas? Venutius I’ll pay to help me.
thank you zimou13 but I don’t see how this would help me. Seems like a form?
$user_phone is xprofile id 206 and $worker_phone is xprofile is id 7
the fields are $user_phone and $worker_phone
So what you do is create a shortcode similar to what you did for the profile pages but it’s within the appointments+ files. I can adjust the code to create the shortcode USER_PHONEr . Here is an example of custom code for a drop down on profile that was included into email templates
if($r->travel_type==2){
$address=$r->address;
$travel_type=”Photographer Travel to Me”;
} else {
$sql = “SELECT * FROMwppl_friends_locator
where member_id=”.$r->worker;$squad=$wpdb->get_results( $sql );
if($squad){
$address=$squad[0]->formatted_address;
}
else{
$address=””;
}
$travel_type=”Travel to Photographer”;
}but instead of all the travel type and address stuff I need to call the xprofile fields database then find id 206 and display that info.
Thank You
Thank you so much for replying. There is quite a lot of data on the plugin page. I need to display it within a backend email template. I am already able to show xprofile fields on the profile. Any ideas?
add_action( ‘wp’, function() {
if ( bp_is_user_profile() ) {
$user_meta = get_userdata( bp_displayed_user_id() );if ( in_array( ‘subscriber’, $user_meta->roles ) ) {
wp_redirect( home_url() );
exit;
}
}
}, 1 );Dude again thanks so much for your help after like 5 hours ha I figure out the simple thing I needed to change
instead of if ( bp_is_user()
I changed it to
if ( bp_is_user_profile()
and now my other pages r visible how I need to subscribers and the subscriber profile is blocked.
2 beers and much streaming sports to solve this and again I thank you what’s your paypal email?
it’s the subscriber who needs to be able to access these pages of there own . The contributor doesnt have access or need access
subscribers only need to access
website.com/members/username/appointments
website.com/members/username/messages
website.com/members/username/shutterdrive/
website.com/members/username/profile/editThere is no user profile tabs. I disable them by default. I just have links to the pages I want customer to view.
The code you gave me before works perfect. It’s just they need access to there other pages like messages buddy drive/ edit profile that stuff. Just not the main profile page?
so I prematurely celebrated. So this does work however it also redirects the customer when the go to any pages like messages, buddydrive, ect;
I need to only block access to profile page but still allow them to visit the message or otheread tabs. I don’t use the standard buddypress design I just have custom links in the header alwso
members/username/messages
members/username/buddydrivethey are also redirected to homepage but I just need when they visit
members/username
Thanks again!
YES!!!!!!!!!!!
Your are the MAN!!!!!
THANK YOU SO MUCH!
any additional help?
this code works perfectly to block the admin
// deny access to admins profile. User is redirected to the homepage
function bpfr_hide_admins_profile() {
global $bp;
if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
wp_redirect( home_url() );
exit;
endif;
}
add_action( ‘wp’, ‘bpfr_hide_admins_profile’, 1 );can’t we just change
if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
wp_redirect( home_url() );and make it subscribers in stead of id and loggedin d?
nevermind i see the ; you removed after roles but it still doesn’t work? Is this the entire code or are you using part of this?
function redirect_members() {
// redirect non logged-in members
if ( !is_user_logged_in() ) {
// get the ID of displayed member
$displayed_user = bp_displayed_user_id();
if (in_array($displayed_user,get_subscriber())) {
wp_redirect(site_url(‘/your-new-page-slug’));
exit();
}
}
}
add_action( ‘wp’, ‘redirect_members’, 1 );// get all subscribers
function get_subscribers() {
$blogusers = get_users( ‘role=subscriber’ );
// Array of WP_User objects.
$exclude = array();
foreach ( $blogusers as $user ) {
$exclude[] .= esc_html( $user->ID );
}
return $exclude;
}the code you sent is the same in both message was it supposed to be different?
still white screen