Welcome to WebmasterWorld Guest from 54.162.227.136

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

wordpress plugin, replacing text

replace standard links in content and comments

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

10+ Year Member



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)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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)

10+ Year Member



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

Thanks!

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

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

dc

 

Featured Threads

Hot Threads This Week

Hot Threads This Month