homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
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

 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;



 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.



 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?


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

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



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

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


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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved