Hi expert wp plugin developers, I need help. I have apply bellow code but not working default value and not showing updated notification after clicking save button. When I put all value in option page from dashboard everything is ok. But not showing all updated notification. Please help me.
<?php
function hkhk_options() {
add_menu_page('Scrol Line Admin Settings', 'hk Settings','manage_options',
'hk_settings', 'hk_admin_options');
}
add_action('admin_menu', 'hkhk_options');
function hk_defaults()
{
$hk_options = array(
'back_color' => '#ccc',
);
}
if ( is_admin() ) :
function hk_register_settings () {
register_setting('hkhk_options', 'hk_options', 'hk_validate_options');
}
add_action('admin_init', 'hk_register_settings');
function hk_admin_options() {
global $hk_options;
if ( ! isset( $_REQUEST['updated'] ) )
$_REQUEST['updated'] = false;
?>
<div class="wrap">
<h2>Select Scrol Line Option</h2>
<?php if ( false !== $_REQUEST['updated'] ) : ?>
<div class="update fade"><p><strong><?php _e( 'Options saved' ); ?></strong></p></div>
<?php endif; // If the form has just been submitted, this shows the notification ?>
<form method="post" action="options.php">
<?php $settings=get_option ( 'hk_options', $hk_options ); ?>
<?php settings_fields('hkhk_options'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="back_color"> Back Color </label></th>
<td>
<input id="back_color" type="text" name="hk_options[back_color]" value="<?php esc_attr_e($settings['back_color']); ?>" class="wp-picker-container" /><p class="description"> Choose any color from here for background color. </p>
</td>
</tr>
</table>
<p class="submit"><input type="submit" class="button-primary" value="Save Options" /> </p>
</form>
</div>
<?php
}
function hk_validate_options( $input ){
global $hk_options;
$settings = get_option( 'hk_options', $hk_options );
$input['back_color'] = wp_filter_post_kses( $input['back_color'] );
return $input;
}
endif;
function scrol_line_active() {?>
<?php global $hk_options; $hk_settings = get_option ( 'hk_options', $hk_options ); ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery("body") .hk({
backColor: "<?php echo $hk_settings['back_color']; ?>",
});
});
</script>
<?php
}
add_action ('wp_head', 'scrol_line_active');
?>
You are checking wrong REQUEST parameter. You need to check $_REQUEST['settings-updated'].
When option page is submitted new URL is similar to /wp-admin/admin.php?page=hk_settings&settings-updated=true.
Hope this helps.
Related
I have a nice demo importer which is working fine but with a category post count issue so there is plugin which is fixing this and I'm trying to integrate into my demo importer library.
This plugin here is fixing the issue after demo import but requires to go into the plugin page selecting post types in order to click on submit button.
Well this is the plugin admin page:
<?php
if($_POST) {
if(!check_admin_referer('select_post_types_'.get_current_user_id() )){
echo 'That is not allowed'; exit;
}
$fixes = $_POST['fix'];
foreach($fixes AS $fix_id){
$fix = new Fix_Category_Count();
$fix->post_type = $fix_id;
if($fix->process()){
$updated = TRUE;
}
}
}
?>
<div>
<?php echo "<h2>" . __( 'Fix Category Count Settings', 'fix_category_count' ) . "</h2>"; ?>
<h3>Select Post Types to Fix</h3>
<form name="site_data_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
<div class="sa_block">
<?php
$post_types = get_post_types(array('public'=>TRUE));
foreach($post_types AS $post_type){
?>
<input type="checkbox" class="post_type" name="fix[]" id="fix_<?=$post_type; ?>" value="<?=$post_type; ?>" /> <label for="fix_<?=$post_type; ?>"><?=ucwords(preg_replace("/_/"," ",$post_type)); ?> (<?=$post_type;?>)</label><br />
<?php
}
?>
<br><br>
Select All |
Deselect All
</div>
</div>
<?php wp_nonce_field('select_post_types_'.get_current_user_id()); ?>
<div class="submit">
<input type="submit" name="Submit" value="<?php _e('Fix Categories Now', '' ) ?>" />
</div>
<?php if($updated){ ?>
<div class="updated"><p><strong><?php _e('Categories Updated.' ); ?></strong></p></div>
<? } ?>
</form>
</div>
<script type="text/javascript">
if(jQuery){
jQuery(document).ready(function($){
$('.select_boxes').click(function(e){
e.preventDefault();
if($(this).attr('rel')=='all'){
$('.post_type').each(function() {
this.checked = true;
});
}
else{
$('.post_type').each(function() {
this.checked = false;
});
}
});
});
}
</script>
So the CLASS of the plugin is here
I want to use only the class without the admin page with something like this:
ob_start();
if ( 'complete' == $response['process'] ) {
// Set imported menus to registered theme locations
$locations = get_theme_mod( 'nav_menu_locations' ); // registered menu locations in theme
$menus = wp_get_nav_menus(); // registered menus
if ( $menus ) {
foreach( $menus as $menu ) { // assign menus to theme locations
if( 'Main Menu' == $menu->name ) {
$locations['primary'] = $menu->term_id;
break;
}
}
}
set_theme_mod( 'nav_menu_locations', $locations ); // set menus to locations
global $wp_rewrite;
$wp_rewrite->set_permalink_structure('/%postname%/');
$wp_rewrite->flush_rules();
// I want to add the plugin functionality as a last process here!
}
ob_end_clean();
I'm not a php developer yet but I would like to get this working without fixing the category count using the plugin page options but directly on the function above and with the php class provided by plugin.
Thank you.
I'm building a Wordpress plugin with a settings page in the admin dashboard.
I have several inputs including text fields, checkbox and select dropdowns.
I save the data with a <form> to options.php, as is recommended by Wordpress.
The checkbox and text field values successfully get saved to the database on submit, but the <select> element (the selected option) does not. I can't understand why.
This is my code:
<?php
//Create menu link
function awb_options_menu_link() {
$awb_options_page = add_options_page(
'Add WhatsApp Button Options', // title
'Add WhatsApp Button', // title of the menu link
'manage_options', // capabilities credentials, at least able to X
'awb-options', // menu URL slug
'awb_options_content' // name of the function that displays the option page content
);
}
function awb_validate_inputs( $input ) {
// Create our array for storing the validated options
$output = array();
// Loop through each of the incoming options
foreach( $input as $key => $value ) {
// Check to see if the current option has a value. If so, process it.
if( isset( $input[$key] ) ) {
// Strip all HTML and PHP tags and properly handle quoted strings
$output[$key] = strip_tags( stripslashes( $input[ $key ] ) );
} // end if
} // end foreach
// Return the array processing any additional functions filtered by this action
return apply_filters( 'awb_validate_inputs', $output, $input );
}
// Create a select dropdown form input for awb_settings[distance_from_bottom_mu]
function distance_from_bottom_mu_dropdown_fn() {
$items = array("px", "%");
$option_with_default = isset( $awb_settings['distance_from_bottom_mu'] ) ? $awb_settings['distance_from_bottom_mu'] : '%';
echo "<select id=\"awb_settings[distance_from_bottom_mu]\" name=\"awb_settings[distance_from_bottom_mu]\" style=\"vertical-align: baseline;\">";
foreach($items as $item) {
$selected = ($option_with_default == $item) ? 'selected="selected"' : '';
echo "<option value=\"$item\" $selected>$item</option>";
}
echo "</select>";
}
// Create options page content
function awb_options_content() {
// Init Options Global
global $awb_options;
// Create default button text
$button_text = isset( $awb_options['button_text'] ) ? sanitize_text_field( $awb_options['button_text'] ) : _e('Send us a WhatsApp', 'add-whatsapp-button');
$awb_location_values = array('right', 'left');
ob_start(); ?>
<div class="wrap">
<h2><?php _e('Add WhatsApp Button Settings', 'add-whatsapp-button') ?></h2>
<p><?php _e('Settings page for the Add WhatsApp Button plugin. Check out the preview screen below to see how your button would look on a smartphone before saving your settings to the database.', 'add-whatsapp-button') ?></p>
<form method="POST" action="options.php">
<?php settings_fields('awb_settings_group'); ?>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="awb_settings[enable]"><?php _e('Enable WhatsApp Button', 'add-whatsapp-button') ?></label></th>
<td><input name="awb_settings[enable]" type="checkbox" id="awb_settings[enable]" value="1" <?php checked('1', $awb_options['enable']); ?>></td>
</tr>
<tr>
<th scope="row"><label for="awb_settings[button_text]"><?php _e('Button Text', 'add-whatsapp-button') ?></label></th>
<td>
<input name="awb_settings[button_text]" type="text" id="awb_settings[button_text]" value="<?php echo $button_text; ?>" class="regular-text">
<p class="description"><?php _e('Enter the text you want the button to show. Recommended: up to 18 characters.', 'add-whatsapp-button'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><label for="awb_settings[breakpoint]"><?php _e('Breakpoint', 'add-whatsapp-button') ?></label></th>
<td>
<input name="awb_settings[enable_breakpoint]" type="checkbox" id="awb_settings[enable_breakpoint]" value="1" <?php checked('1', $awb_options['enable_breakpoint']); ?>>
<p class="description"><?php _e('Check this box in order to only display the WhatsApp button up to a certain screen width.', 'add-whatsapp-button'); ?></p>
<div id="awb_breakpoint" class="bp-no-show">
<input name="awb_settings[breakpoint]" type="number" id="awb_settings[breakpoint]" value="<?php echo sanitize_text_field( $awb_options['breakpoint'] ); ?>" class="small-text"><?php _e('px', 'add-whatsapp-button'); ?>
<p class="description"><?php _e('Enter your desired screen width breakpoint here. Default is 600px.', 'add-whatsapp-button'); ?></p>
</div>
</td>
</tr>
<tr>
<th scope="row"><label for="awb_settings[button_bg_color]"><?php _e('Button Background Color', 'add-whatsapp-button') ?></label></th>
<td>
<!-- <input name="awb_settings[button_bg_color]" type="text" id="awb_settings[button_bg_color]" value="<?php //echo $awb_options['button_bg_color']; ?>" class="regular-text" /> -->
<input name="awb_settings[button_bg_color]" type="text" id="awb_settings[button_bg_color]" value="<?php echo sanitize_text_field( $awb_options['button_bg_color'] ); ?>" class="udi-color-picker" />
<p class="description"><?php _e('Choose a background color for your button. Default is green (#20B038)', 'add-whatsapp-button'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><label for="awb_settings[distance_from_bottom]"><?php _e('Button Distance from Bottom', 'add-whatsapp-button') ?></label></th>
<td>
<input name="awb_settings[distance_from_bottom]" type="number" id="awb_settings[distance_from_bottom]" value="<?php echo sanitize_text_field( $awb_options['distance_from_bottom'] ); ?>" class="small-text" />
<?php distance_from_bottom_mu_dropdown_fn(); ?>
<p class="description"><?php _e('Choose your button\'s Distance from the bottom of the screen, in percentages or pixels. Default is 10%.', 'add-whatsapp-button'); ?></p>
</td>
</tr>
<th scope="row"><label for="awb_settings[button_location]"><?php _e('Button Location on Screen', 'add-whatsapp-button') ?></label></th>
<td>
<select id="awb_settings[button_location]" name="awb_settings[button_location]" style="vertical-align: baseline;">
<option value="right" <?php selected( $awb_settings['button_location'], 'right' ); ?>>right</option>
<option value="left" <?php selected( $awb_settings['button_location'], 'left' ); ?>>left</option>
</select>
<p class="description"><?php _e('Choose whether your button will appear on the left side or right side of the screen', 'add-whatsapp-button'); ?></p>
</td>
</tr>
</tbody>
</table>
<h2><?php _e('Button Preview', 'add-whatsapp-button'); ?></h2>
<div class="device-wrapper"> <!-- Mockup Container -->
<div class="device" data-device="iPhone7" data-orientation="portrait" data-color="black">
<div class="screen">
<div id="admin-wab-cont" class="wab-cont"> <!-- Button Preview HTML -->
<a id="whatsAppButton" href="https://api.whatsapp.com/send?phone=972544480070&text=%D7%94%D7%99%D7%99%2C%20%D7%90%D7%A4%D7%A9%D7%A8%20%D7%9C%D7%A9%D7%9E%D7%95%D7%A2%20%D7%A4%D7%A8%D7%98%D7%99%D7%9D%20%D7%A2%D7%9C%20%D7%91%D7%A8%D7%99%D7%AA%20%D7%9E%D7%99%D7%9C%D7%94%2F%D7%98%D7%99%D7%A4%D7%95%D7%9C%20%D7%91%D7%9C%D7%A9%D7%95%D7%9F%20%D7%A7%D7%A9%D7%95%D7%A8%D7%94%3F" target="_blank"><?php echo $button_text; ?> <!--<img src="<?php //echo plugins_url( '../img/wai.svg', __FILE__ ) ?>" style="max-width: 20px; display: inline;" />--></a>
</div>
</div> <!-- /screen -->
<div class="button">
<!-- You can hook the "home button" to some JavaScript events or just remove it -->
</div>
</div> <!-- /device -->
</div> <!-- /device-wrapper -->
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e('Save Changes', 'add-whatsapp-button') ?>"></p>
</form>
</div>
<script>
console.log(<?php echo $awb_settings['button_location'] ?>);
</script>
<?php
echo ob_get_clean();
}
add_action('admin_menu', 'awb_options_menu_link');
//register plugin settings
function awb_register_settings() {
register_setting('awb_settings_group', 'awb_settings', 'awb_validate_inputs');
}
add_action('admin_init', 'awb_register_settings');
Anyone have any idea why the <select> option value does not save to the database?
I printed out the $awb_options array with print_r, and it turns out the value is indeed saved into the database correctly, but the saved value wouldn't display properly.
After re-examining my code I noticed I mixed up $awb_settings (which I used to post the settings to the DB) and $awb_options, which is the variable in the wp_options table that actually holds the array of saved settings. I accidentally called $awb_settings['button_location'] and not $awb_options['button_location'] in the input value. That was my mistake... A stupid one I would agree.
I am not able to call the search term in functions.php file from search.php file. I am trying to achieve this through the use of script.
$search_term should be called but it is not being called. If I replace it with certain keywords, posts shows perfectly. I want to call search term input by user using the search form.
search.php
<?php $search_query = get_search_query(); ?>
<div align="center">
<h2>Search Results For "<?php echo $search_query ?>"</h2>
</div>
<div class="entry-content" style="margin:2% 0 0 0;">
<?php if (have_posts()) : ?>
<div class="col-lg-12 col-md-12 col-sm-12 my-posts" style="padding:0 1% 1% 1%;">
<?php while (have_posts()) : the_post(); ?>
<?php
echo "<div>";
This Part Shows Content
echo "</div>";
?>
<?php endwhile ?>
</div>
<?php endif ?>
</div>
<div class="loadmore" style="text-align:center;font-size:1.4em;color:#4a235a;padding:1% 0 1% 0;font-weight:900;">
<button type="button" style="background-color: #f44336;width:98%;border-radius:6px;border:2px solid #4a235a;">Load More Posts</button>
</div>
<script type="text/javascript">
var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
var page = 2;
jQuery(function($) {
$('body').on('click', '.loadmore', function() {
var data = {
'action': 'load_posts_by_ajax_search',
'page': page,
'searchTerm': $('#s').val(),
'security': '<?php echo wp_create_nonce("load_more_posts_search"); ?>'
};
$.post(ajaxurl, data, function(response) {
$('.my-posts').append(response);
page++;
});
});
});
</script>
functions.php
add_action('wp_ajax_load_posts_by_ajax_search', 'load_posts_by_ajax_callback_search');
add_action('wp_ajax_nopriv_load_posts_by_ajax_search', 'load_posts_by_ajax_callback_search');
function load_posts_by_ajax_callback_search() {
check_ajax_referer('load_more_posts_search', 'security');
$paged_search = $_POST['page'];
$search_term = esc_attr($_POST['searchTerm']);
$args_search = array(
'posts_per_page' => '20',
's' => $search_term,
'paged' => $paged_search,
);
$my_posts_search = new WP_Query( $args_search );
if ( $my_posts_search->have_posts() ) :
?>
<?php while ( $my_posts_search->have_posts() ) : $my_posts_search->the_post() ?>
<?php
echo "<div>";
This Part Shows Content
echo "</div>";
?>
<?php endwhile ?>
<?php endif; ?>
My searchform.php code
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>" target="_self">
<div>
<input style="text-align:center;width:100%;margin:0 0 12px; 0;border-color:#4a235a;color:#000000;" placeholder='Eg:Location,Skill,Company' class="text" type="text" value="" name="s" id="s" />
</div>
<div>
<input type="submit" style="text-align:center;margin:0 0 0 0;width:100%;border:1.5px solid;border-color:grey;background-color:#4a235a;color:#f4511e;" class="submit button" name="submit" value="<?php _e('Search');?>" />
</div>
</form>
Hi I am developing a word press website. I created a custom template, where in I have a form and fields are inserted into the database(mySql). The Codes are shown below.Insert into database
Now I require to display the data which are already inserted into the database in front end in form of a table or grid. How I am able to do that.
I need the output something like this.
Ritual Name Ritual Active
---------------------------
Test1 | Y
Test2 | Y
Any help appreciated.
function.php
function childtheme_style_andscripts(){
//wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_script('ajax-function', get_stylesheet_directory_uri() . '/js/ajaxfunction.js', array('jquery'), '1.0', true );
wp_localize_script( 'ajax-function', 'usersubmitform', array(
'url'=> admin_url('admin-ajax.php'),
'security'=> wp_create_nonce('our-nonce')
) );
}
add_action('wp_enqueue_scripts','childtheme_style_andscripts');
function form_action_function() {
require_once(dirname( __FILE__ ).'/../../../wp-load.php');
$data = $_POST['data'];
global $wpdb;
if( !check_ajax_referer('our-nonce', 'security' ) ) {
wp_send_json_error('security failed');
return;
}
//var_dump($data);
$rname=$data['rname'];
$ractive=$data['ractive'];
$table_name = "rituals";
$wpdb->insert($table_name, array ('Ritual_Name' => $rname, 'Ritual_Active' => $ractive) );
//$wpdb->show_errors();
//$wpdb->print_error();
echo 'From Submitted Successfully';
die();
}
add_action('wp_ajax_nopriv_form_action_function','form_action_function');
add_action('wp_ajax_form_action_function','form_action_function');
ajaxfunction.js
jQuery(document).ready(function($){
var submitButton = document.getElementById('usersubmit');
var ajaxFunctionformprocess = function(fromdata, action){
$.ajax({
type:'post',
url: usersubmitform.url,
data:{
action:action,
data:fromdata,
security:usersubmitform.security,
},
success:function(reponse){
$('div.msg').html(reponse);
},
error:function(response){
alert(response);
}
});
}
submitButton.addEventListener('click', function(event){
event.preventDefault();
var fromdata = {
'rname':document.getElementById('rname').value,
'ractive':document.getElementById('ractive').value,
};
ajaxFunctionformprocess(fromdata, 'form_action_function');
});
});
Samplepage.php(custom template)
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<h1 class="headingform">User Form</h1>
<div class="msg"></div>
<form class="userform">
Ritual Name: <input type="text" id="rname" name="rname" /><br> <br>
Ritual Active: <input type="text" id="ractive" name="ractive" /> <br><br>
<input id="usersubmit"type="submit" Value="Submit" />
</form>
</div><!-- #content -->
</div><!-- #primary -->
Case 1 :Create a template for display information from table
<?php
/*
Template Name: Disply Ritural
Description: display ritual information in table formate
*/
global $wpdb;
$table_name = "rituals";
$result = $wpdb->get_results ("SELECT * FROM $table_name");
foreach ( $result as $ritual_info )
{
echo $ritual_info['Ritual_Name'];
echo $ritual_info['Ritual_Active'];
}
Case 2 :Create a shortcode make it easy to use.open your functions.php file add code there.
function show_ritual_info(){
global $wpdb;
$table_name = "rituals";
$query="SELECT * FROM $table_name";
$result = $wpdb->get_results ($query);
foreach ( $result as $ritual_info )
{
echo $ritual_info['Ritual_Name'];
echo $ritual_info['Ritual_Active'];
}
}
add_shortcode('show_ritual_info','show_ritual_info');
How to use shortcode
Inside php file
<?php echo do_shortcode('[show_ritual_info]'); ?>
Inside admin page
['show_ritual_info']
Something like this:
<?php
global $wpdb;
$table_name = "rituals";
// this will get the data from your table
$retrieve_data = $wpdb->get_results( "SELECT * FROM $table_name" );
?>
<?php if( ! empty($retrieve_data) ):?>
<table>
<tr>
<th>Ritual Name</th>
<th>Ritual Active</th>
</tr>
<?php foreach ($retrieve_data as $retrieved_data): ?>
<tr>
<td><?php echo $retrieved_data['Ritual_Name'];?></td>
<td><?php echo $retrieved_data['Ritual_Active'];?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
Not check but must work.)
I have created the following wordpress page template:
<?php
/* Template Name: Report Creator */
get_header();
wp_enqueue_style( 'wp-admin' );
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
?>
<style>
.table td{
padding-left:0;
}
</style>
<!-- ############################### -->
<?php
if(isset($_POST['function-action'])){
$function_action = $_POST['function-action'];
switch($function_action){
case 'form-edit-profile':
break;
case 'form-delete-profile':
wp_delete_post(); //pass ID over here to delete the post
break;
default:
break;
}
}
?>
<table>
<tr>
<th>Titel</th>
<th>Creation Date</th>
<th>Next fetch time</th>
<th># of Recipience</th>
<th>Functions</th>
</tr>
<?php
if ( is_user_logged_in() ):
global $current_user;
$author_query = array('post_status' => array( 'draft' ),
'author' => $current_user->ID,
'meta_query' => array(
array(
'key' => 'wpgamail_options',
'key' => 'ganalytics_settings',
),
),);
$author_posts = new WP_Query($author_query);
while($author_posts->have_posts()) : $author_posts->the_post();
?>
<tr>
<td>
<?php the_title(); ?>
</td>
<td>
<?php $post_date = get_the_date(); echo $post_date; ?>
</td>
<td>
<?php $field = get_field('wpgamail_options', get_the_ID(), true); echo "Next report on " . date('l jS \of F Y h:i:s A', $field['nextfetchtime']); ?>
</td>
<td>
<?php echo count($field['recipients']) . " Recipient"; ?>
</td>
<td>
<form method="post">
<input type="hidden" name="function-action" value="form-edit-profile"/>
<input type="submit" value="Edit Profile" class="button button-primary" />
</form>
</td>
<td>
<form method="post">
<input type="hidden" name="function-action" value="form-delete-profile"/>
<input type="submit" value="Delete Profile" class="button button-primary" onclick="return confirm('Do you really want to delete the report-settings?')" />
</form>
</td>
</tr>
<?php
endwhile;
else :
echo "You are not logged in. Please log in!";
endif;
?>
</table>
<hr/>
</main>
<!-- .site-main -->
</div>
<!-- .content-area -->
<?php get_footer(); ?>
My problem is that I do not know how to pass the id of the currently selected post to the switch-caseconstruct in order to delete / edit the post.
Any suggestions how to do that?
I appreciate your replies!
Try this.
Your HTML
<form method="post">
<input type="hidden" name="function-action" value="form-delete-profile" />
<input type="hidden" name="this_id" value="<?php echo get_the_ID(); ?>" />
<input type="submit" value="Delete Profile" class="button button-primary" onclick="return confirm('Do you really want to delete the report-settings?')" />
</form>
Your PHP
<?php
if(isset($_POST['function-action'])){
$function_action = $_POST['function-action'];
$this_id = (int)$_POST['this_id'];
$post_author = get_post_field( 'post_author', $this_id ); //Get post's author
switch($function_action){
case 'form-edit-profile':
break;
case 'form-delete-profile':
if( $post_author == get_current_user_id() ) { //This condition is to check that currect is the author of this post
wp_delete_post( $this_id ); //pass ID over here to delete the post
} else{
echo "You don't have permission to delete it.!";
}
break;
default:
break;
}
}
?>
Good luck