Using Dynamic Content with http request headers

We are looking to implement a conditional section depending on http request header of the page:

eg: Section 1 would show if request headers would contain “CF-IPCountry” == “DE”

Is there a way to achieve this currently?

Also, I couldn’t find any documentation first the list of all supported dc args, it would really help if that’s included on the documentation

Hello @Planet,

Thanks for writing in! Regretfully we do not have a dynamic content that returns the HTTP request header. What we do have at the moment, is the URL parameter dynamic content. Please check out this thread:

Best Regards.

Hi @ruenel

We managed to make it work with the follow snippet

function register_header() { cornerstone_dynamic_content_register_field(array(
    'name'  => 'cf_country',
    'group' => 'global',
    'label' => 'cf_country'
  ));
}

function supply_field_headers( $result, $field, $args) {
  switch ($field) {
    case 'cf_country':
	  return $_SERVER["HTTP_CF_IPCOUNTRY"];
  }
}

add_filter('cs_dynamic_content_global', 'supply_field_headers', 10, 3 );
add_action('cs_dynamic_content_setup', 'register_header');

It should be quite easy to expose all headers and maybe even cookies. I think this would make dc: even more powerful.

Hey Planet,

We’re glad that you’re able to figure it out! If you have any other concerns or clarifications regarding our theme features, feel fee to open up a new thread.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.