homepage Welcome to WebmasterWorld Guest from 54.237.95.6
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
wordpress plugin, replacing text
replace standard links in content and comments
David_M




msg:3488195
 10:47 am on Oct 26, 2007 (gmt 0)

Any ideas why this isn't working?

I'm trying to replace the standard wordpress login, logout, and signup, links with a new directory $new_url defined earlier in the plugin.
It seems to be showing up as blank... Also the replacement is not working properly when I tested defining the variable within the replacelinks function.

add_filter('the_content', 'replacelinks');
add_filter('comment_text', 'replacelinks');
function replacelinks($content) {
$registerurl = get_bloginfo('url').'/wp-login.php?action=register';
$content = str_replace($registerurl, $new_url.'signup.php', $content);
$profileurl = get_bloginfo('url').'/wp-admin/profile.php';
$content = str_replace($profileurl, $new_url.'profile.php', $content);

$logouturl = get_bloginfo('url').'/wp-login.php?action=logout';
$content = str_replace($logouturl, $new_url.'logout.php', $content);

$loginurl = get_bloginfo('url').'/wp-login.php';
$content = str_replace($loginurl, $new_url.'login.php', $content);

return $content;
}

 

dreamcatcher




msg:3488197
 10:50 am on Oct 26, 2007 (gmt 0)

Hi David_M,

My guess is you should have some of the vars declared outside of the function as global vars inside the function.

dc

David_M




msg:3488200
 11:15 am on Oct 26, 2007 (gmt 0)

This what you mean?
function replacelinks($content) {
global $new_url;

I've also tried placing global within the main function in which $new_url is defined. didn't work.

Other ideas?

David_M




msg:3488203
 11:19 am on Oct 26, 2007 (gmt 0)

got it, placed it in both of the functions :)

Thanks!

dreamcatcher




msg:3488293
 1:51 pm on Oct 26, 2007 (gmt 0)

Yep, sorry, been busy today. Glad you got it working.

dc

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved