php - Wordpress - ACF field rewrite slug issue -


so having issue have spent way long on. getting error: fatal error: call undefined function get_current_screen() in /home1/teamv/public_html/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php on line 3252

when run code in functions.php

// hidden fieldss function acf_review_before_save_post($post_id) {     if (empty($_post['acf']))         return;      $current_user = wp_get_current_user();     $value = $_post['acf']['field_578b7b3470e26']; // address     $_post['acf']['_post_title'] = '( '.$_post['acf']['field_578ce02b9f472'].' ) - ' . $value['address'];     $_post['acf']['_post_content'] = $value['address'];     $_post['acf']['field_578f32d3ff97e'] = $value['lat'];     $_post['acf']['field_578f32e8ff97f'] = $value['lng'];      $_post['acf']['field_578e1d7b97981'] = $current_user->display_name;     return $post_id; } add_action('acf/pre_save_post', 'acf_review_before_save_post', -1);   //change things when saave acf function my_acf_save_post( $post_id ) {      $new_slug = $_post['acf']['field_578ce02b9f472'];     $new_slug = sanitize_title($new_slug);     $new_slug .= '-'.$post_id;      $my_post = array(       'id'           => $post_id,       'post_name'   => $new_slug,     );      wp_update_post( $my_post ); }  // run after acf saves $_post['acf'] data add_action('acf/save_post', 'my_acf_save_post', 1); 

what trying do, update both post title, content, custom lat, lng field google map, adding user, working fine, however, when updating post slug, error mentioned above. can't figure out on earth wrong. can please me out, appreciate :) way, advanced custom fields issue. documentation here > https://www.advancedcustomfields.com/resources/acfsave_post/


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -