Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP code for Trigger with Action
<?php
global $current_user;
get_currentuserinfo();
$userid = get_userdata($current_user->ID);
//adds Bootstrap Styling
$pdocrud = new PDOCrud(false, "pure", "pure");
$pdocrud->setTriggerOperation("wp_booking", array("int_id" => array("type" => "fixed", "val" =>"$userid->user_id")),array(),
"update", "after_btn_switch_update");
//renames columns and displays specific columns
$pdocrud->colRename("booking_profname", "Professional Name");
$pdocrud->colRename("booking_language", "Language");
$pdocrud->colRename("booking_date", "Date Required");
$pdocrud->colRename("booking_time", "Time Required");
$pdocrud->colRename("booking_duration", "Duration");
$pdocrud->colRename("booking_interviewname", "Interviewee Name");
$pdocrud->colRename("booking_type", "Type");
$pdocrud->crudTableCol(array("booking_id","booking_profname","booking_language","booking_date","booking_time","booking_duration","booking_interviewname","booking_status","booking_type","int_id"));
//removing column
//change Data format to m-d-Y
$pdocrud->TableColFormatting("booking_date", "date", array("format" => "m-d-Y"));
$pdocrud->tableHeading("Available Bookings Table");
//dynamically show current users languages and Gender Specific
$pdocrud-> where("booking_language", "$userid->lang_1");
$pdocrud-> where("booking_gender", "$userid->int_gender");
$pdocrud-> where("booking_status", "Pending");
//action to make the self allocation work from an action button
$action = array("Pending" => "Accepted");//action to be performed, like when value is 1 set it to 0
$text = array("Pending" => '<i class="fa fa-check-square" aria-hidden="true"></i>',"Accepted"=>'<i class="fa fa-arrow-up" aria-hidden="true"></i>');
$attr = array("title"=>"Accept Session Button");
$pdocrud->enqueueBtnActions("btnswitch", $action, "btnswitch",$text,"booking_status", $attr);
echo $pdocrud->dbTable("wp_booking")->render();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.