1. Home
  2. Docs
  3. Add-Ons
  4. Property Import
  5. Redirecting Links From Mailouts

Redirecting Links From Mailouts

Redirects Handled For You From Version 1.1.67

From version 1.1.67 of the import add on we handle redirects for you without needing to add the bespoke code below.

For Jupix customers

Simply get mailouts to link to you homepage followed by '?profileID=X' (i.e. https://your-site.com?profileID=X)

For everyone else

Simply get mailouts to link to you homepage followed by '?imported_id=X' (i.e. https://your-site.com?imported_id=X)

When Using Version 1.1.66 or Older

Jupix

add_action('init', 'check_jupix_redirect');
function check_jupix_redirect()
{
    if ( isset($_GET['profileID']) )
    {
        $args = array(
            'post_type' => 'property',
            'meta_key'     => '_imported_ref_1491659041', // CHANGE '1491659041' TO BE ID OF IMPORT
            'meta_value'   => $_GET['profileID']
        );
        $my_query = new WP_Query( $args );

        if ( $my_query->have_posts() )
        {
            while ( $my_query->have_posts() )
            {
                $my_query->the_post();

                header("HTTP/1.1 301 Moved Permanently");
                header("Location: " . get_permalink(get_the_ID()));

                exit();
            }

        }
        wp_reset_postdata();
    }
}

ReapIT / JET

add_action('init', 'check_jet_reapit_redirect');
function check_jet_reapit_redirect()
{
    if ( isset($_GET['pid']) )
    {
        $args = array(
            'post_type' => 'property',
            'meta_query' => array(
                array(
                    'key' => '_imported_ref_1491659041',  // CHANGE '1491659041' TO BE ID OF IMPORT
                    'value' => $_GET['pid'],
                    'compare' => 'LIKE'
                )
            )
        );
        $my_query = new WP_Query( $args );

        if ( $my_query->have_posts() )
        {
            while ( $my_query->have_posts() )
            {
                $my_query->the_post();

                header("HTTP/1.1 301 Moved Permanently");
                header("Location: " . get_permalink(get_the_ID()));

                exit();
            }

        }
        wp_reset_postdata();
    }
}