Forum Moderators: coopster

Message Too Old, No Replies

php inside echo

         

PiratePictures

4:16 pm on Mar 8, 2010 (gmt 0)

10+ Year Member



i've tried all the things posted in the other threads but can't seem to get this specific code to work. any help would be very appreciated.

<?php
$mysitename = get_bloginfo('name');
$mysitefeed = get_bloginfo('rss2_url');

if (get_option('greeting') || get_option('welcomemessage')) {
if (get_option('greeting')) {
echo "<h2>" . get_option('greeting') . "</h2>";
}
if (get_option('welcomemessage')) {
echo "<p>" . get_option('welcomemessage') . "</p>";
}
} else {
echo "<h2>Welcome to $mysitename!</h2><p>You can now login.</p><p>CLICK HERE TO LOGIN</p>";
}

?>

I'm trying to make "CLICK HERE TO LOGIN" clickable with this (i think...): <?php wp_register(); ?><li><?php wp_loginout(); ?>

Can't seem to figure out how to replace echo with proper code... too complicated for a newbie.

thanks in advance.

Matthew1980

4:24 pm on Mar 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there PiratePictures,

Welcome to the forum ;-p

Concatenation is what your after:-


<?php
$mysitename = get_bloginfo('name');
$mysitefeed = get_bloginfo('rss2_url');

if (get_option('greeting') || get_option('welcomemessage')) {
if (get_option('greeting')) {
echo "<h2>" . get_option('greeting') . "</h2>";
}
if (get_option('welcomemessage')) {
echo "<p>" . get_option('welcomemessage') . "</p>";
}
} else {
echo "<h2>Welcome to $mysitename!</h2><p>You can now login.</p><p>".wp_register()."</p><p>".wp_login_out()."</p>";
}
?>


Im not sure whether this is what you were tring to achieve or not, but that looks like what you were after, try that, see how you get on.

Replace the <p> tags with whatever you are needing there, I just used that as an example.

Cheers,

MRb

eatspinach

4:25 pm on Mar 8, 2010 (gmt 0)

10+ Year Member



echo "<h2>Welcome to dave</h2><p>You can now login.</p><a href='www.google.ie' >CLICK HERE TO LOGIN</a>";

or

?>
Welcome to dave</h2><p>You can now login.</p><a href='www.google.ie' >CLICK HERE TO LOGIN</a>

<?php

PiratePictures

4:32 pm on Mar 8, 2010 (gmt 0)

10+ Year Member



thanks for such a quick answer.

i tried that before and it 1) puts the login button on top of everything else (Welcome to my site, etc.) and 2) it has the generic text "Login" instead of CLICK HERE TO LOGIN.

ideas?

you're more than welcome to check out the bones of the site here:

[edited by: jatar_k at 5:06 pm (utc) on Mar 8, 2010]
[edit reason] no urls thanks [/edit]

Matthew1980

4:38 pm on Mar 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there PiratePictures,

Sounds like there is something amis in the function you are trying to echo to screen?

It just depends where in the script the clause is placed as to where it ends up in the page, and if your using css, make sure that the classes are correct, especially when your using DIV.

Cheers,

MRb

PiratePictures

5:08 pm on Mar 8, 2010 (gmt 0)

10+ Year Member



hmm. seems like too much effort to fix for a simple login. i'll just do it with a href.

thanks!

Matthew1980

7:37 pm on Mar 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there PiratePictures,

It depends on how the function is constructed and how the data is formatted into the return instruction, I also just noticed a typo in my previous post (should have read wp_loginout().) I had given you an extra underscore ;p!

Post back if your direct link functions or if you just want want the function checked over for any *obvious* errors in syntax.

Hopefully though, the direct route will be a suitable quick fix.

Good luck for the rest of the project,

Cheers,

MRb