Advertisement:

Author Topic: How to put a redirect url on the...  (Read 1132 times)

developGr

  • Full Member
  • ***
  • Posts: 161
How to put a redirect url on the...
« on: December 06, 2017, 07:22:33 pm »
How to put a redirect url to the item-post.php after the user click on publish listing?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to put a redirect url on the...
« Reply #1 on: December 06, 2017, 07:32:23 pm »
Hi,

Where do you want to redirect?

Regards

developGr

  • Full Member
  • ***
  • Posts: 161
Re: How to put a redirect url on the...
« Reply #2 on: December 06, 2017, 07:42:24 pm »
for example to the user dashboard page

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to put a redirect url on the...
« Reply #3 on: December 06, 2017, 08:17:03 pm »
Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.

Code: [Select]
<?php
function redirect_to_user_dashboard() {
    
header('Location: ' osc_user_dashboard_url());
    exit;
}

osc_add_hook('posted_item''redirect_to_user_dashboard');
?>


Regards

developGr

  • Full Member
  • ***
  • Posts: 161
Re: How to put a redirect url on the...
« Reply #4 on: December 06, 2017, 08:29:12 pm »
And if i want to redirect to a specific url lets say "www.example.com" ?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to put a redirect url on the...
« Reply #5 on: December 06, 2017, 09:14:55 pm »
Replace osc_user_dashboard_url() with osc_base_url()

Here you have a bunch of url helpers:

https://doc.osclass.org/HDefines.php#Helpers_for_the_public_website
« Last Edit: December 06, 2017, 11:10:46 pm by teseo »

developGr

  • Full Member
  • ***
  • Posts: 161
Re: How to put a redirect url on the...
« Reply #6 on: December 06, 2017, 09:27:44 pm »
ok! but if i want to use a link like that (http://www.google.com) how i will do it!!?

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: How to put a redirect url on the...
« Reply #7 on: December 06, 2017, 09:49:53 pm »
« Last Edit: December 06, 2017, 09:51:52 pm by marius-ciclistu »

developGr

  • Full Member
  • ***
  • Posts: 161
Re: How to put a redirect url on the...
« Reply #8 on: December 06, 2017, 10:16:25 pm »
i am talking about that osc_user_dashboard_url() with osc_base_url()

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to put a redirect url on the...
« Reply #9 on: December 06, 2017, 11:10:11 pm »
I misunderstood you, marius already gave you the answer.

developGr

  • Full Member
  • ***
  • Posts: 161
Re: How to put a redirect url on the...
« Reply #10 on: December 06, 2017, 11:51:32 pm »
where i will put that header('Location: http://www.google.com'); ?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to put a redirect url on the...
« Reply #11 on: December 07, 2017, 12:06:52 am »
Replacing:

header('Location: ' . osc_user_dashboard_url());

In the function I gave you.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: How to put a redirect url on the...
« Reply #12 on: October 03, 2018, 04:47:08 am »
Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.

Code: [Select]
<?php
function redirect_to_user_dashboard() {
    
header('Location: ' osc_user_dashboard_url());
    exit;
}

osc_add_hook('posted_item''redirect_to_user_dashboard');
?>


Regards

@teseo
this code works but it has one problem,
test this and see the result: (bender theme)
1. publish a listing. (put a value for searchable custom-fields).
2. now directly go to search.php page.
3. now on the sidebar search, you can see the searchable custom-fields have the search values of recently published listing's custom-fields values.
regards,

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: How to put a redirect url on the...
« Reply #13 on: October 03, 2018, 12:08:22 pm »
Hello,

It seems like the POST variable isn't cleared when redirecting. Maybe adding "$_POST = array();" before "Header..." will fix it? I'm not sure if it's safe though.

Regards.