Title: Hide section elements based on GEO Content
Last modified: March 27, 2018

---

# Hide section elements based on GEO Content

 *  Resolved [Eric De Kock](https://wordpress.org/support/users/ericdk/)
 * (@ericdk)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/hide-section-elements-based-on-geo-content/)
 * Hi there
 * I’m busy developing our new website with the elementor page builder. I have added
   a custom control which adds a custom class to each section element.
 * The reason for this is that we display certain products based on the specific
   state. I detect users according to their ip and based on their state I can hide
   the content not relevant to them.
 * What I would like to do before the items render on the pages I would like to 
   only render the state-specific sections to make the page lighter for the user.
 * Please let me know if this makes sense and if you need any more details from 
   me.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhide-section-elements-based-on-geo-content%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Eric De Kock](https://wordpress.org/support/users/ericdk/)
 * (@ericdk)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/hide-section-elements-based-on-geo-content/#post-10118220)
 * Just to give you an idea what I have done thus far.
 * Below is the control I have created which will add the class show-‘state’ to 
   the section.
 * In the section action you will notice that I’m checking each section’s setting
   and comparing the setting with the current active user state.
 * My last step would be to print the element if the user state and the section 
   state are equel. How would I print only that element.
 * add_action( ‘elementor/element/before_section_start’, function( $element, $section_id,
   $args ) {
    /** [@var](https://wordpress.org/support/users/var/) \Elementor\Element_Base
   $element */ if ( ‘section’ === $element->get_name() && ‘section_background’ =
   == $section_id ) {
 *  $element->start_controls_section(
    ‘states’, [ ‘tab’ => \Elementor\Controls_Manager::
   TAB_STYLE, ‘label’ => __( ‘States’, ‘state-select’ ), ] );
 *  $element->add_control(
    ‘custom_control’, [ ‘type’ => \Elementor\Controls_Manager::
   SELECT, ‘label’ => __( ‘Choose your state’, ‘state-select’ ), ‘default’ => ‘sa’,‘
   options’ => array( ‘all’ => ‘ALL’, ‘sa’ => ‘SA’, ‘wa’ => ‘WA’, ‘nsw’ => ‘NSW’,‘
   vic’ => ‘VIC’, ‘qld’ => ‘QLD’, ‘act’ => ‘ACT’ ), ‘prefix_class’ => ‘show-‘, ‘
   label_block’ => true, ] ); $element->end_controls_section(); } }, 10, 3 );
 * add_action( ‘elementor/frontend/element/before_render’, function ( \Elementor\
   Element_Base $element ) {
    if ( ‘section’ === $element->get_name() ) { //$geoip2_state
   = strtolower( get_geoip2_country_state( get_visitor_IP() ) ); $activestate = 
   $element->get_settings( ‘custom_control’ );
 *  if ( $activestate == $_COOKIE[‘userState’] ):
    echo ‘eq: ‘ . $activestate; //
   $element->print_element();
 *  else:
    //$element->print_element(); echo ‘not eq: ‘ . $activestate; endif; }});
 *  [benpines](https://wordpress.org/support/users/benpines/)
 * (@benpines)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/hide-section-elements-based-on-geo-content/#post-10316263)
 * This is beyond the scope of this forum

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hide section elements based on GEO Content’ is closed to new replies.

 * ![](https://ps.w.org/elementor/assets/icon-256x256.gif?rev=3444228)
 * [Elementor Website Builder - more than just a page builder](https://wordpress.org/plugins/elementor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/elementor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/elementor/)
 * [Active Topics](https://wordpress.org/support/plugin/elementor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elementor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elementor/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [benpines](https://wordpress.org/support/users/benpines/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/hide-section-elements-based-on-geo-content/#post-10316263)
 * Status: resolved