I have content only available to registered users - guests see an intro but if they click to read more are shown a message to login or register - I need to add a link to the registration page in the message they see.
Here is what I have tried:
if (!$user->guest) {
echo $this->item->fulltext;
}
else
echo '<h3><b>Please login or <a herf="/login/register">register</a> to view the entire article</b></h3>';
?>
My text shows correctly & the word register turns blue, but it is not linking.
Please advise. Thank you in advance.
When you can tell me what a herf is, I'll wonder myself.
It's spelled href not herf.
=>
register
Related
In WooCommerce login/registration page, I try to add a statement "Ask for help" under the login/registration form next to "Forget password?"
To let the unregistered user go easily to the "Contact Us" when pressing on this statement.
I guess you could insert an echo. Something like this if you can locate the position on PHP when your form happens:
echo "<p><a href='contactus.html'>Ask for help</a></p>";
It's hard without seeing the code though. Maybe you can have access to the html form and can edit it from there.
This will add the link in the appropriate places where Woocommerce provides action hooks:
add_action('woocommerce_login_form_end', 'custom_woocommerce_help_link_action');
add_action('woocommerce_after_lost_password_form', 'custom_woocommerce_help_link_action');
function custom_woocommerce_help_link_action() {
echo '<p class="ask-help">Ask for help</p>';
}
Obviously change the link URL to suit and style the paragraph as needed.
i'm working on an E-commerce website and i'm willing to do the back end with PHP, so there is an index page (default) which opens after you browse the website's link which contains the offers, products etc.. so there is a navigation bar with sign up and log in buttons, what i need to do is after the log in i want the same index page opened with some differences (log in button replaced with account button with a profile picture for example and the sign up replaced with log out button) without going to another directory.. how can i do that exactly please ?
Just create conditions in PHP, if the user is connected then you display X elements, else you post other elements!
if (!empty($_SESSION['id']) { echo 'User is connected'; } else { echo 'User is not connected'; }
I want to display this text link, <p>Click here to register.</p> in the body of a larger block of text on a page and but I want the link to show up when some is logged in. I want to use php conditional to show this other link when someone is instead anonymous on the site,
<p>You need to login before you can register. Please Click here to login.
I want a code like:
<?php
if user=="logged-in";
echo "<a href ='register'>Click here to register.</a>";
else echo "<a href ='login'>Click here to login.</a>"
?>
I know I must not have written perfect php but I do not have problems with the php, what I need is the Drupal syntax for if user == "logged-in" and if user == "not-logged-in".
I do not want to use a block and start setting visibility by role. I want to use code as described.
Thanks.
See the docs
You want something like this. Both of your link descriptions need some work though. What you'd most likely want to do is display both the register and the login link to anonymous users.
<?php
if (user_is_logged_in()){
//user is logged in
}
else{
//user is not logged in
}
?>
I've a database (image1) and using PHPMaker i created the graphic interface (image2). What i want is to add a button at the bottom of the page that will print the selected data from the selected fields (image3).
Can anyone tell me how to do that?
Do i have to use php code or a javascript?
Just add a print link by echoing the following to create a "Print" link on the page
echo "<a href='#' onclick='javascript:window.print();'>Print Page</a>";
Button click will make the browser present the user with the default print dialog.
I'm working with the Zend Framework on a project that requires the user to activate their account by checking their email and clicking on the activation link. The activation link works fine and the user can login once their account is set active. My question is how can i display a message when the user clicks on the activation link and get redirected to the home page, acknowledging that their account has been activated.
I was trying to write an if statement to check if HTTP_REFERER = the URL of the activation link. But that didn't work. Any help would be greatly appreciated.
Here's the if statement:
<script language="javascript" type="text/javascript">
$(document).ready(function() {
<?php if ($_SERVER['HTTP_REFERER'] == 'activationLinkGoesHere'){ ?>
$("#suc_message").html('<?php echo 'Your account has been activated!';?>');
$("#suc_message").fadeIn(2000);
$("#suc_message").fadeOut(20000);
<?php } ?>
});
</script>
Thanks :)
Is there a reason you couldn't set a session variable on the activation page and then check for it in php on the home page? If it's set, use php to inject some javascript (just a simple boolean flag should do) that you then check when the page loads.
If you use Zend Framework, then you must use FlashMessenger. It's designed for that exact purpose.
Remember to use the helper's static method in your controller's action.
Then for the view use noumenal's excellent view helper; you can then put it in your layout or view script.
It's that easy. Hope it helps.
Sorry for the original answer, I did not read this properly.
I personally would just add something on the end of the url:
http://mysite.com/thanks.php?Reg=1
..and look for the reg part and inject the message if it exists.
edit
Returning to this, I'll add that it is very important to keep the url addition to something that is a boolean value. For example, you could display multiple messages if you found ?Reg=1 or ?LoggedIn=1 and displayed "You registered OK" and "You logged in OK" respectively.
Don't pass anything in that your javascript then uses for display or otherwise.
Don't make it fire any actions.
Follow the above and you'll be safe from people fiddling with the url to have fun with you.