Show global Message in User Profiles with admin only Input field in WordPress Backend

You just need to move the capability check “inwards”: function wpse_230369_quote_of_the_day( $user ) { $quote = esc_attr( get_option( ‘quote_of_the_day’ ) ); ?> <div class=”visible-only-for-admin”> <h3>Quote of the Day Input Field</h3> <table class=”form-table” > <tr> <th><label for=”quote_of_the_day”>Quote of the Day</label></th> <td> <?php if ( current_user_can( ‘administrator’ ) ) : ?> <input type=”text” name=”quote_of_the_day” value=”<?php echo $quote … Read more

register_settings callback function erases data

in case of wrong value, the function has to return the original value then try this : function email_validation($data, $option, $original_value) { if (null == $data) { add_settings_error( ‘requiredTextFieldEmpty’, ’empty’, ‘Notification Email cannot be empty’, ‘error’ ); return $original_value; } else { if (!is_email($data)){ add_settings_error( ‘requiredTextFieldEmpty’, ’empty’, ‘Notification Email is not valid email address’, ‘error’ … Read more

How to reinstate previously saved option?

The only way WordPress is going to know what the previous option was, is if you save it before you change it – since you’re replacing the built-in option, it has no way of knowing how to get back to that. So, you could add a custom ‘backup’ option that you restore on deactivation. Something … Read more

“options.php” not found

Like @LupuAndrei said, we lack of details, especially the code where you call you form from. But I suspect, again like @LupuAndrei said, you might not be calling the settings_fields, do_settings_fields or do_settings_sections correctly. On the function where you build your form, try something like this <form method=”post” action=”options.php”> <table class=”form-table”> <?php settings_fields( ‘animated-settings-group’ ); … Read more

Is it possible to change slugs’ default behaviour?

Test you the following filter work for you: function wpse245094_fist_duplicate_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { // slug had to change, we must have a duplicate if ( $original_slug !== $slug ) { // try to replace `-2` with `-es` $new_slug = preg_replace( ‘#-2$#’, ‘-es’, $slug ); if ( $new_slug !== $slug ) … Read more

403 error on submit at the plugin options page

I have solved this by adding the word “content” to the field name <textarea rows=”5″ cols=”20″ name=”ad1_content”><?php echo stripslashes( get_option(‘ad1_content’) )?></textarea> It then worked just fine I think this is a security issue that accepted the script tag for fields containing content (used by wordpress in editor by the way) in name and rejecting the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)