• Resolved uili

    (@uili)


    Im trying to insert a dynamic parameters to the new url that would be something like:

    url.com/events
    redirect to
    url.com/events?category=festivais&date_from=2018-07-26

    this works fine inserting a fixed date but what I want to do is to make the date dynamic do get Today’s date.. i know its nothing related to your plugin but im looking everywhere trying to make it work.

    Perhaps someone could show me how to do it even if I need to do in .htaccess or functions.php

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Godley

    (@johnny5)

    You will need to create your own code for this. You can find a list of Redirection hooks here:

    https://github.com/johngodley/redirection

    For example, you could use the redirection_url_target hook to add the current date.

    Thread Starter uili

    (@uili)

    right, actually im not that good with php, but i just found out that we can use Dynamic URL Data just like %userid% and stuffs, so i added one more inside your plugin, in function replace_special_tags() like:

    $date = date('Y-m-d');
    $url = str_replace( '%date%', isset( $date ) ? $date : '', $url );

    turning to this:

    public function replace_special_tags( $url ) {
    
        $date = date('Y-m-d');
        $url = str_replace( '%date%', isset( $date ) ? $date : '', $url );
    
        if ( is_numeric( $url ) ) {
            $url = get_permalink( $url );
        } else {
            $user = wp_get_current_user();
            if ( ! empty( $user ) ) {
                $url = str_replace( '%userid%', $user->ID, $url );
                $url = str_replace( '%userlogin%', isset( $user->user_login ) ? $user->user_login : '', $url );
                $url = str_replace( '%userurl%', isset( $user->user_url ) ? $user->user_url : '', $url );
    
            }
        }
    
        return $url;
    }

    And worked just how i wanted, but is there a way to add this in functions.php instead moding your plugin, so i dont loose this in next update? How can i use your hooks to achieve this?

    thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Redirect with custom parameter’ is closed to new replies.