Forums/Community Help

Answered

PURL Not Found page for wordpress

olavpgn
asked this on June 16, 2011 10:26 am

Can i change the PURL Not found page for Purlem's wordpress Plugin? Or link to another page?
(it is hard to believe but some customers can type it wrong)

 

Comments

User photo
Marty Thomas
Purlem
Ajax_loader_small Answer

Ya.. You can but it will take a little customization.

In your wordpress admin go to Plugins. Then select edit under Purlem's plugin.

REDIRECT THE USER
Once in the editor, find the line:

$_SESSION['user'] = $user;

(about 1/3 of the way down in the display_purl_code function)


Under that line add the following:

if(!$_SESSION['user']->{'firstName'}) {
header( 'Location: http://www.yoursite.com/new_page.html' ) ;
}

Replace the URL with the place you would like to redirect to when the PURL is not found.

CHANGE THE "PURL NOT FOUND" PAGE

Or you can change the content that is displayed when the PURL is not found.  To do that...

Once in the editor, find the line:

$newContent .= '<div style="background-color: white;padding: 10px;margin-top: 10px;margin-bottom: 10px;border: 1px solid #ddd;"><img src="http://www.purlem.com/assets/images/logo_white.gif" width="157" height="41"><br><br><strong>PURL Not Found</strong><br> Check your Purlem Plugin Settings<br>Need an account? <a href="http://www.purlem.com">Sign Up </a></div>';

And replace the content within the single quotes ($newContent .= ' with the content you would like to appear.

--------
Just a for-warning.... If you update the plugin, you will have to re-add this code.

I'll consider adding this as a feature for our next release...

June 16, 2011 10:40 am
User photo
Matt Fiore

Hi again Marty,

Thought I'd ask this question here so others can benefit...

I just made the changes in the code above to REDIRECT THE USER however I'm getting a syntax error?...

Parse error: syntax error, unexpected $end in.../purlem-personal-url-marketing/purlem.php on line 264

Here's how the code looks...

function display_purl_code() {
$data = @file_get_contents('http://www.purlapi.com/lp/index.php?ID='.$_GET["ID"].'&name='.$_GET["purl"].'&page='.$_GET["page"].'&test='.$_GET["test"].'&wordpress='.$_GET["wordpress"]); $user = json_decode($data); @session_start(); if($_GET['username']) $_SESSION['visitor']=$_GET['username']; if($user->{'login'} && ($_SESSION['visitor'] != $user->{'purl1'})) { echo $user->{'login'}; exit; }
$_SESSION['user'] = $user;
if(!$_SESSION['user']->{'firstName'}) {
header( 'Location: http://www.mysite.com/error-page' ) ;
}

function display_purl_content($content) {
$newContent .= purl_convert($content);

if($_GET['wordpress'] == 'Y') {
$newContent .= $_SESSION['user']->{'content'};
if(get_option('showPurlForm') == 'Y') $newContent .= $_SESSION['user']->{'form'};

if(!$_SESSION['user']->{'firstName'}) {
$newContent .= '<b>PURL NOT FOUND</b> Please try again.';
}
}

Obviously I've changed the redirect URL for privacy ;)

Hope you can help.

Matt

August 02, 2011 03:24 pm
User photo
Marty Thomas
Purlem

Looks like your missing the closing bracket for the display_purl_code function.  Should be:

 

function display_purl_code() {
$data = @file_get_contents('http://www.purlapi.com/lp/index.php?ID='.$_GET["ID"].'&name='.$_GET["purl"].'&page='.$_GET["page"].'&test='.$_GET["test"].'&wordpress='.$_GET["wordpress"]); $user = json_decode($data); @session_start(); if($_GET['username']) $_SESSION['visitor']=$_GET['username']; if($user->{'login'} && ($_SESSION['visitor'] != $user->{'purl1'})) { echo $user->{'login'}; exit; }
$_SESSION['user'] = $user;
if(!$_SESSION['user']->{'firstName'}) {
header( 'Location: http://www.mysite.com/error-page' ) ;
}
}  //this is the closing bracket your missing

August 02, 2011 03:35 pm
User photo
Matt Fiore

Marty, I'm sure I'd tried that originally, so I just did it again and I think I'm getting some sort of clash with the theme I'm using, here's what I get when I mistype a purl with the closing bracket added...

Warning: Cannot modify header information - headers already sent by (output started at .../wp-content/themes/OptimizePress/launch_002d.php:3) in .../plugins/purlem-personal-url-marketing/purlem.php on line 76

Is there a way to redirect without using the headers?

August 02, 2011 04:31 pm
User photo
Marty Thomas
Purlem

Really???  And it is within the display_purl_code function?  I'm not sure about this one.  Would you be able to create a login for me to your wordpress admin?  I'll login and see if I can't see why that is happening...

August 02, 2011 06:52 pm