How to keep the capability of users and disable Gutenberg editor in WordPress?

add these lines in your ‘functions.php’, it will work //if not gutenberg reapprove posts add_filter( ‘wp_insert_post_data’, ‘re_aprove’, ’99’, 2 ); function re_aprove( $data, $postarr ) { //check if current user is not admin if ( ! current_user_can( ‘manage_options’ ) ) { if ( ‘publish’ === $data[‘post_status’] ) { $data[‘post_status’] = ‘pending’; } } return $data; … Read more

how to save checkbox data for custom setting?

Your checkbox data is saved as 1 or ” if someone checked or unchecked it. you can also verify this using var_dump($checkbox) inside custom_checkbox_field_html function This should work. function custom_checkbox_field_html(){ $checkbox = get_option( ‘disabletitle_text’ ); $is_checked = ( $checkbox != ” && $checkbox == 1 ) ? ‘checked’: ”; printf( ‘<input type=”checkbox” id=”disabletitle_text” name=”disabletitle_text” value=”1″ … Read more

Fix error Gravatar alt

You don’t check anywhere that you’re viewing a comment when you use get_comment_author();. The get_avatar() function is used in a lot of places in WordPress; your code seems to assume it’s only in use on comments. Try this (the code is untested, but should work, I think): add_filter( ‘get_avatar’ , ‘alt_name_avatar’); function alt_name_avatar( $avatar ) … Read more

Convert code – not work

I changed it a little. But the code doesn’t work for some reason 🙁 You should explain what exactly happened or did not happen that should have happened, rather than simply saying “doesn’t work”. But anyway, if the first and fifth lines below were the only changes you applied in the code: add_action( ‘wp_insert_post_data’, ‘adding_image_dimensions’ … Read more

Redirection after submitting duplicate comment

This answer lets you redirect back to the originating post instead of dieing with the flood message. It’s a PHP class, not just a simple function. You can copy-paste this into your functions.php as-is, or set it up in whichever way you like to manage your custom code. assumes PHP 5.3+ it also contains code … Read more

How to get User Time Zone in WordPress?

Since WordPress is a server-side framework/CMS, it likely doesn’t have the functionality you’re looking for. If you’re looking for ways to obtain this information, the most reliable would likely be to ask the user. To make it as painless as possible for the user, this functionality could be achieved via client-side scripting (ie. JavaScript) where … Read more

Why can’t I return a value from $wpdb->get var?

get_results() by default returns each databse row as object, so $survey_mapping is an array of objects. Therefore you should replace $row with $row->surveyid in the second query: $dup_survey2 = absint( $wpdb->get_var( $wpdb->prepare(“SELECT surveyls_survey_id FROM oc_surveys_languagesettings WHERE surveyls_survey_id = %d”, $row->surveyid) )); and in $wpdb->delete(): array(‘surveyid’ => absint($row->surveyid)) By the way, you can use a single … Read more