Prevent publish status/date saved on transition_post_status hook

I think that hook fires after the post status has been updated. Try this add_action( ‘pre_post_update’, ‘intercept_adherence_publishing’, 10, 2); function intercept_adherence_publishing ($post_ID, $data ) { if (get_post_type($post_ID) !== ‘protocol-adherence’) { return; } $post = get_post($post_ID); $adherence_status = $_POST[‘_adherence_status’]; if ( ( $data[‘post_status’] === ‘publish’ ) && ( $post->post_type == ‘protocol-adherence’ ) && ( $adherence_status !== … Read more

Custom Widget outputs the input but doesn’t save anything inside the textarea

Your primary issue isn’t with saving the data but displaying in the form if it has been saved. I rewrote the offending function: function form($instance) { $title = strip_tags( $instance[‘title’] ); $info = esc_textarea( $instance[‘info’] ); // var_dump($instance); // debug ?> <p> <label for=”<?php echo $this->get_field_id(‘title’); ?>”><?php _e(‘Title:’); ?></label> <input class=”widefat” id=”<?php echo $this->get_field_id(‘title’); ?>” … Read more

Can we have a php “page” without a WordPress “page”?

Well, inside your directory just keep a normal php file like my-page.php, and then create a vanity URL for it using .htaccess. Open your .htaccess file (if present in the nstallation directory) or create one RewriteEngine On RewriteRule ^my-page-slug my-page.php Should be good update if you want to access WP posts and other objects, you … Read more

Jquery ajax to custom php file: returning blank data

You are going on the wrong way.This will create difficulties and is NOT WORDPRESS STANDARD.Wordpress has a ajax technique to implement this. Call the ajax from your page <script> var data = { ‘action’: ‘insert_data_customtable’, ‘first_name’: firstname, ‘last_name’: lastname }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php … Read more

How to create different menu’s for not logged in visitors and for logged in members?

You can do that by using 2 different menus (wp_nav_menu). use is_user_logged_in conditional tag and apply a different menu accordingly: if (is_user_logged_in()) { wp_nav_menu(array(‘theme_location’ => ‘logged_user’ )); } else { wp_nav_menu(array(‘theme_location’ => ‘new_user’ )); } Edit This code goes where you’d usually put your regular menu in the theme – probably header.php Also, make sure … Read more

populate dropdown wordpress form from database custom table

Thanks everybody for your answers. You bring me value clues. Finally I opted to make the query directly from wordpress page with the wordpress sintax for the defaults wordpress tables, using a little trick: Including my custom tables in wp-includes/wp-db.php. wordpress code: <?php global $current_user; get_currentuserinfo(); $user = $current_user->ID; global $wpdb; global $result; $courses = … Read more

Create a new user using WP REST API and declare meta object

Just found the solution in another question of Stack Overflow. Using the function register_meta(): register_meta(‘user’, ‘icq’, array( “type” => “string”, “show_in_rest” => true )); Now I can make a request using: { “username” : “johndoe”, “email”: “[email protected]”, “password”: “qwerty”, “meta”: { “icq”: “11223344” } } And the response are: { “id”: 49, “username”: “johndoe”, “name”: … Read more