get_pages Drop down list for selection of a page

You already have <option value=””>…</option> you just need some extra attrs for it You need to load current value and if value equals $page->ID than add attr selected=”selected” Here’s how it could be done: <select name=”easyreg_redirect_page”> <option selected=”selected” disabled=”disabled” value=””><?php echo esc_attr( __( ‘Select page’ ) ); ?></option> <?php $selected_page = get_option( ‘option_key’ ); $pages … Read more

Save Checkbox value in Plugin [duplicate]

If a checkbox is unchecked, it doesn’t get submitted with the form values. So when using checkboxes, you should have an else statement for isset( $_POST[‘iwmp_settings_form_submitted’] ) and it basically will be triggered when the checkbox is unchecked. Here’s the fixed code. //Global Variable $options = array(); //Options Page function iwmp_options_page() { if( ! current_user_can( … Read more

How to add settings subpage from a plugin to a settings page created in theme?

This is just a typo Wrong //wvdh-startpoint add_submenu_page( ‘wvdh-startpoint’, ‘page-from-plugin’, ‘menu-from-plugin’, ‘manage_options’, ‘plugin-slug’, ‘wvdh_settings_page’ ); Correct //wdvh-startpoint add_submenu_page( ‘wdvh-startpoint’, ‘page-from-plugin’, ‘menu-from-plugin’, ‘manage_options’, ‘plugin-slug’, ‘wvdh_settings_page’ );

WordPress security issue to output data from user input from theme option form

Security issues arise when you write code that open up possibilities for outsiders to access your database or otherwise compromise your installation. The above code just reads options and content from the database and translates this into static html that will be send to the browser of the page’s visitor. There’s no code (like a … Read more

How to delete an user including data from custom database tables

Hello guys! i resolved this issue by using same hook add_action( ‘delete_user’, ‘my_delete_user’ ); here is my code <?php function my_delete_user( $user_id ) { global $wpdb; $user_obj = get_userdata( $user_id ); $id_user = $user_obj->ID; $idsss = $user_obj->user_id; /*Delete Data from friend table*/ $query_friend= $wpdb->query(“DELETE FROM `wp_user_friends` where `friend_id` = “.$user_obj->ID.””); /*delete data from group*/ $delete_group_table … Read more