Support

Account

Forum Replies Created

  • Thanks for the help James, ‘exclude’ has resolved my issue.

  • Hi James,
    Thanks for the quick response. However, I have created a brand new installation of Twentyseventeen and tested with the default post and page with no other plugins installed and I get the same issue.

    In this situation, I have added a Field Group to POSTS with a single Post Object field:

    Post Object Field Screengrab

    In my functions file, I have the following filter to exclude the Sample Page with an ID of 2:

    Functions File Filter

    But when I select the Field on a post, you can see that the Sample Page is still available for selection:

    Post Object Dropdown on POST admin screen

    What am I doing wrong?

    Appreciate your help and have a great Christmas ;o)

  • Hi Elliot, I have the answer:

    function my_function( $value ) {
        if ( empty( $value ) ) :
    	$value = $_POST['fields']['field_5252ea93ea1f6'] . $_POST['fields']['field_5252aeaf0a86b'];
            return $value;
        endif;
        return $value;
    }
    add_filter('title_save_pre', 'my_function');

    Sorry for the Newbie questions and thanks for your help.

    Regards, Ian.

  • Hi Elliot thanks for the heads-up and first-class support.

    For those that are interested, I resolved my issue with the following code:

    function MY_FUNCTION_NAME( $value ) {
    	if ( !$value ) : // IF VALUE EMPTY, RETURN NEW VALUE
    		$value = get_field( 'MY_CUSTOM_FIELD_NAME', $POST_ID) );
    		return $value;
    	endif;
    		return $value; // RETURN EXISTING VALUE
    };
    add_filter( 'acf/load_value/name=MY_CUSTOM_FIELD_NAME', 'MY_FUNCTION_NAME' );
  • Thanks Elliot, that make a lot of sense… I’m new to backend development so I was wondering if you could point me in the right direction for using the $_POST array and field key?

    I’ve tried the following code without success:

    function my_function( $value ) {
        if ( empty( $value ) ) :
            return $_POST['field_5252ea93ea1f6'] .  $_POST['field_5252aeaf0a86b'];
        endif;
        return $value;
    }
    add_filter('title_save_pre', 'my_function');

    Am I going off in the completely wrong direction?

    Thanks, Ian.

  • OK, so this works on UPDATE but not on PUBLISH when the initial post is created:

    function my_function( $value ) {
        if ( empty( $value ) ) :
            return get_field( "firstname" ) .  get_field( "lastname" );
        endif;
        return $value;
    }
    add_filter('title_save_pre', 'my_function');

    Any ideas anyone?

Viewing 6 posts - 1 through 6 (of 6 total)