What could cause a WP Option to get truncated?

It was a 👼 character. Make sure you sanitize everything that gets written as field values, even if it’s a username. trim(preg_replace(“/[^\w\s]+/”, “”, $user->full_name)) I assumed there are no special characters in Instagram usernames. Never assume. I don’t really use Instagram, just my plugin supports it. BTW it got truncated on the first occurrence of … Read more

How to automatically redirect to custom admin menu after plugin activation?

You can use register_activation_hook(). Add this to your plugin, tested and works. register_activation_hook(__FILE__, ‘redirect_after_activation’); function redirect_after_activation() { add_option(‘redirect_after_activation_option’, true); } add_action(‘admin_init’, ‘activation_redirect’); function activation_redirect() { if (get_option(‘redirect_after_activation_option’, false)) { delete_option(‘redirect_after_activation_option’); exit(wp_redirect(admin_url( ‘wp-admin/admin.php?page=axl_ads’ ))); } }

How to save custom form data in wp_options table

@Buttered_Toast’s solutions is what you are looking for, if you were in a position to use it. There are a bunch of problems with your code. Variables $confused_about_treatment_editor, $estimated_price_editor, and $satisfaction_guarantee_editor are never instantiated. The values of $option_name and $option_valueare changed three times, but only the last value is ever used. There is no closing … Read more

Warn user that data may be lost for custom pages

you have to make a javascript code similar to this… jQuery(function ($) { name = $(‘#name’).val(); $(‘#name’).data(‘old_value’,name); window.onbeforeunload = function () { if ($(‘#name’).data(‘old_value’) !== $(‘#name’).val()) return ‘You have unsaved changes!’; } }); here’s a demo page… try closing the page after changing the value of the textbox there…