Skip to content

Instantly share code, notes, and snippets.

View rafiahmedd's full-sized avatar
💻
def code:

Rafi Ahmed rafiahmedd

💻
def code:
View GitHub Profile
@rafiahmedd
rafiahmedd / Send Email To All Unpaid Users FF
Last active August 4, 2021 22:20
Send hourly email to the users who don't pay the total yet.
//Send Email To unpaid/pending users via cron job wp (FF payment status = pending)
/**
* this method will register event to WordPress init
*/
add_action( 'init', 'sendEmailToPaymentPendingUsers');
function sendEmailToPaymentPendingUsers(){
if( !wp_next_scheduled( 'notify_unpaid_users' ) ) {
// schedule an event
//Available Event Types (hourly, twicedaily, daily, weekly, fifteendays, monthly)
@rafiahmedd
rafiahmedd / Hash password if the user status is unconfirm
Created August 4, 2021 22:45
Hash password if the user status is unconfirm
add_filter( 'fluentform_response_render_input_password', function($response_field_key, $field, $formId, $isHtml){
$hash = str_repeat("*", strlen($response_field_key)).' '. __('(truncated)', 'fluentform');
return $hash;
} , 10, 4);
@rafiahmedd
rafiahmedd / Show total paid amount anywhere of a site using php api ff
Created August 4, 2021 22:45
Show total paid amount anywhere of a site using php api ff
function get_total_amount() {
$formApi = fluentFormApi('forms')->entryInstance($formId = 5);
$entries = $formApi->entries();
$totalEntries = count($entries);
$totalPaid=0;
for($i=0; $i<$totalEntries; $i++){
if($entries['data'][$i]->payment_status === 'paid'){
$totalPaid+= (($entries['data'][$i]->payment_total)/100);
@rafiahmedd
rafiahmedd / Adding data from RSS feed to FF dropdown
Created August 4, 2021 22:46
Adding data from RSS feed to FF dropdown
add_filter('fluenform_rendering_field_data_select', function ($data, $form) {
//Repleace the 44 with your form id
if ($form->id != 44) {
return $data;
}
// check if the name attriibute is 'dropdown'
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'dropdown') {
return $data;
}
$feeds = [];
@rafiahmedd
rafiahmedd / Trigger an email when payment status changed
Created August 4, 2021 22:48
Trigger an email when payment status changed
add_action('fluentform_after_payment_status_change', 'emailNotification',10,2);
function emailNotification($newStatus, $submission){
if($newStatus!='pending'){
$to = $submission->response['email']; // You set your email here
$subject = 'Your order change to '. $submission->payment_status;
$message = 'Hi '.$submission->response['names']['first_name'].','.'<br>';
$message.='Your order change to '. $submission->payment_status;
}
return wp_mail( $to, $subject, $message);
}
@rafiahmedd
rafiahmedd / Email Attachment from a external link
Last active November 9, 2022 07:09
Email Attachment from a external link
@rafiahmedd
rafiahmedd / Redirect to a page after payment success
Created August 4, 2021 22:50
Redirect to a page after payment success
$method = ['paypal','stripe'];
foreach($method as $mode){
add_action('fluent_payment_frameless_'.$mode, 'afterPayment',10,1);
}
function afterPayment($data){
//$tansiction = FluentFormPro\Payments\PaymentMethods\BaseProcessor::getTransaction($data['transaction_hash'],'transaction_hash');
//dd($tansiction->status);
/*if($data['type']== 'success' && $tansiction->status){
echo "<script>
window.location.href='https://google.com';
@rafiahmedd
rafiahmedd / Number format at PDF separate shortcode
Created August 4, 2021 22:50
Number format at PDF separate shortcode
add_filter('fluentform_response_render_input_number', function ($response, $field, $form_id, $isHtml = true) {
if (!$response ) {
return $response;
}
$fieldSettings = \FluentForm\Framework\Helpers\ArrayHelper::get($field, 'raw.settings');
$formatter = \FluentForm\Framework\Helpers\ArrayHelper::get($fieldSettings, 'numeric_formatter');
if (!$formatter) {
return $response;
}
@rafiahmedd
rafiahmedd / Phone field validate err mes change
Created August 4, 2021 22:51
Phone field validate err mes change
add_filter('fluentform_validation_message_phone_valid_phone_number', function($msg){
$msg = "Err";
return $msg;
},10,1);
@rafiahmedd
rafiahmedd / Add Serial number to targeted table
Created August 4, 2021 22:52
Add Serial number to targeted table
add_filter('ninja_table_rendering_table_vars',function($table_vars, $table_id, $tableArray){
$target_id = [2607,2608];
$tableId = 0;
foreach($target_id as $id){
if($table_id == $id){
$tableId = $id;
}
}