• Resolved Peter

    (@digitalform)


    Hi!

    I would like to use the code below as a base.

    add_filter( ‘frou_sanitize_file_name’, function($filename_infs){
    $filename_infs[‘structure’][‘translation’][‘my_custom_rule’] = get_current_user_id();
    return $filename_infs;
    }, 20 );

    It doesn’t work: $filename_infs[‘structure’][‘translation’][‘my_custom_rule’] = get_the_ID();

    How do I get back the post ID (not the get_current_user_id)?

    Bets regards,
    Peter

    • This topic was modified 2 years ago by Peter.
Viewing 1 replies (of 1 total)
  • Thread Starter Peter

    (@digitalform)

    Update:
    Unfortunately, I don’t get all ACF fields back. And I want to translate some fields by “if”.

    I use this code:

    add_filter('frou_sanitize_file_name', function($filename_infs) { 
        
    	global $post;
    	
    	$p_id = $post['ID'];
    	
    	// Buy or rent
    	$buy_rent = '';
    	if (get_field('buy_rent', $p_id) == 'buy') { 
    		$buy_rent = 'elado';
    	} else {
    		$buy_rent = 'kiado';
    	}
    	
    	$filename_infs['structure']['translation']['my_custom_rule'] = $buy_rent.'-property-'.$p_id;
    	
    	return $filename_infs;
    }, 20);

    UPDATE 2:
    I got the ID with this: $p_id = \FROU\WordPress\Post::get_parent_post_id();

    • This reply was modified 2 years ago by Peter.
Viewing 1 replies (of 1 total)
  • The topic ‘Get back the post ID’ is closed to new replies.