Software Developer

Add Login Form To Lazyest Gallery If User Not Logged In

This page is in the Code Graveyard where I lay to rest snippets of code that I don't use anymore. Some have lost their usefulness due to the evolving nature of the web, while others have been replaced with better code. "Be Ye Warned!"

PROBLEM:
If you make your Lazyest Gallery (Lazyest Gallery Plugin by Macbrink) only visible to logged-in users, the gallery will display a message like this: “Please log in or register to view the gallery.” But it doesn’t add a link to login, or a login form.

To make the Lazyest Gallery more user-friendly for my visitors, I add a login form below the message. This encourages visitors to stay and view the gallery. The login form also has a link to register. (BTW, I love the Lazyest Gallery plugin; it’s actually my single favorite WordPress plugin.)

To add a regular WordPress login/register form to the Lazyest Gallery message to users who are not logged in, do the following:

FILE TO EDIT:
wp-content/plugins/lazyest-gallery/lazyest-gallery.php

Find the following code, which should be line 992:

  printf( '<p>%s</p>', $message );

Change the code above to this new code:

 printf( '<p class="loginmsg">%s</p>', $message );wp_login_form();

You may notice that I also added a CSS class to the message above. You can remove that if you like.

NOTE: This code modifies the plugin core. If you do this, keep a change log of your changes. You’ll have to make these changes again after upgrading the Lazyest Gallery plugin to a new version. As always, modifications made to the plugin core will be overridden when you upgrade the plugin. The extra work is worth it to me, for a plugin that does what I want it to do. I keep a simple changelog, and re-doing the changes after an upgrade takes me about 2 minutes.

By

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]