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

Accessing GET variable named ‘error’

Your problem is that you’re using Reserved Terms. error is a reserved term, you can’t use it. To get around this, you could intercept the request early, and do a redirect, changing the query parameters in the process. For example, handling a link get parameter: add_action( ‘wp’ , ‘reserved_term_intercept’ ); function reserved_term_intercept(){ global $wp_query; if( … Read more

Get all of user’s custom post types in WP Admin for plugin

By passing the _builtin argument to get_post_types(), only WordPress default post types will be returned. Instead, just pass public as an arguement, Here’s an example of output on a development site with WooCommerce activated: var_dump(get_post_types([‘public’ => true])); //result array(4) { [“post”]=> string(4) “post” [“page”]=> string(4) “page” [“attachment”]=> string(10) “attachment” [“product”]=> string(7) “product” } With no … Read more