Run a function on certain pages and other function on other pages

Completed Posted 2 years ago Paid on delivery
Completed Paid on delivery

Hi, we have a custom function that runs on all website and it is ok, but in admin and user dashboard it prevents the showing of data we need because it checks if a variable has value and of course on private page it hasn't a value. We're trying to run a function only on pages that contains "/listing/" url fragment and on all other pages run the default function, is it possible? I'm attaching code:

DEFAULT FUNCTION THAT SHOWS DATA AND HAS TO RUN:

/*

public function render( $props ) {

$module = $this->create( $props );

if( ! Rz()->is_error( $module ) ) {

echo $module->get();

}else{

$module->display_error();

}

}

*/

CUSTOM FUNCTION THAT HAS TO RUN INSTEAD OF THE ONE ABOVE ONLY ON PAGES THAT HAVE "/listing/" INSIDE THEIR URL:

public function render( $props ) {

$module = $this->create( $props );

if( ! Rz()->is_error( $module ) ) {

$id = get_the_ID();

$key_1_values = get_post_meta( $id, 'rz_chatok' , true);

$key_2_values = get_post_meta( $id, 'rz_richiestaprev' , true);

if(is_array($props))

{

if(isset($props['type']) && $props['type']=='contact')

{

if((isset($key_1_values) && $key_1_values<>''))

{

echo $module->get();

}

}

else

if(isset($props['type']) && $props['type']=='application')

{

if((isset($key_2_values) && $key_2_values<>''))

{

echo $module->get();

}

}

else

{

echo $module->get();

}

}

else

{

echo $module->get();

}

}else{

$module->display_error();

}

}

PHP JavaScript Software Architecture MySQL AJAX

Project ID: #32315917

About the project

4 proposals Remote project Active 2 years ago

Awarded to:

(258 Reviews)
7.9

4 freelancers are bidding on average €29 for this job

akhileshsharma09

Hi I can run the function on only urls containing listing string, I assure you that I can do this Please contact me via chat to get started. Waiting for opportunity Thank you so much

€30 EUR in 1 day
(77 Reviews)
5.8