Support

Account

Home Forums General Issues Forming URL from 2 fields

Helping

Forming URL from 2 fields

  • Hi! I want to form a URL from 2 fields. Field 1 will have a value entered, and Field 2 will take that value and enter it into a line of code to form a longer URL. Is that possible please? Example below:

    Field 1: number
    Field 2: https://xxx/<field1>/abcd

    Question 2: Can Field 2 be read only? Field 2 will be used in the web site builder as a shortcode.

  • Hi idesignandhost

    Question 1.
    Yes, you can simply use php concatenate. For example:

    
    $field_1 = get_field('field_1');
    $field_2 = get_field('field_2');
    
    $join_me = 'Hello, using a . joins things together: '.$field_1.' and '.$field_2;

    Question 2
    You can try something like:

    
    function wp_disable_acf_fields( $field ) {
    	if( !is_admin() ){
    		$field['disabled'] = 1;
    	
    	}
    	return $field;
    }
    add_filter('acf/load_field/key=field_5996a05bc0d7d', 'wp_disable_acf_fields');	#replace field key
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.