latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Login shortcode

Home Forums Community Forum Login shortcode

This topic contains 8 replies, has 4 voices. Last updated by  Jim Climy 4 years, 6 months ago.

Topic Author Topic
Posted: Wednesday Jun 6th, 2012 at 6:57 am #15676

Is their a login shortcode that I can use instead of the login widget?

List Of Topic Replies

Viewing 8 replies - 1 through 8 (of 8 total)
Author Replies
Author Replies
Posted: Wednesday Jun 6th, 2012 at 8:28 am #15680
David Welch
Username: dwbiz05

Try adding this to your theme’s functions.php file:

<?php
add_shortcode('my-login-shortcode','my_login_shortcode');

function my_login_shortcode(){
	return s2member_pro_login_widget();
}
?>

Then use this shortcode:

[my-login-shortcode \]

I have not tested this to it’s full extent, but it seemed to work for me. I don’t know that there is a standard shortcode for this. I didn’t see one.

Hope that helps.

Dave

Posted: Wednesday Jun 6th, 2012 at 9:15 am #15683
David Welch
Username: dwbiz05

Also, I found this in the s2member Codex:

s2member_pro_login_widget()
public  str s2member_pro_login_widget (array $options, array $args)
Allows for the inclusion of the Pro Login Widget directly into a theme/plugin file.
This function will return the HTML output from the widget function call. Example usage: <?php echo s2member_pro_login_widget(); ?>
The $options parameter (array) is completely optional ( i.e. NOT required ). It can be passed in as an array of options; overriding some or all of these defaults:
"title" => "Membership Login" Title when NOT logged in, or leave this blank if you'd prefer not to show a title.
"signup_url" => "%%automatic%%" Full Signup URL, or use %%automatic%% for the Membership Options Page. If you leave this blank, it will not be shown.
"login_redirect" => "" Empty ( i.e. "" ) = Login Welcome Page, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own.
"logged_out_code" => "" HTML/PHP code to display when logged out. May also contain WP Shortcodes if you like.
"profile_title" => "My Profile Summary" Title when a User is logged in. Or you can leave this blank if you'd prefer not to show a title.
"display_gravatar" => "1" Display Gravatar image when logged in? 1 = yes, 0 = no. Gravatars are based on email address.
"link_gravatar" => "1" Link Gravatar image to Gravatar.com? 1 = yes, 0 = no. Allows Users to setup a Gravatar.
"display_name" => "1" Display the current User's WordPress® "Display Name" when logged in? 1 = yes, 0 = no.
"logged_in_code" => "" HTML/PHP code to display when logged in. May also contain WP Shortcodes if you like.
"logout_redirect" => "%%home%%" Empty ( i.e. "" ) = Login Screen, %%previous%% = Previous Page, %%home%% = Home Page, or use a full URL of your own.
"my_account_url" => "%%automatic%%" Full URL of your own, or use %%automatic%% for the Login Welcome Page. Leave empty to not show this at all.
"my_profile_url" => "%%automatic%%" Full URL of your own, or use %%automatic%% for a JavaScript popup. Leave empty to not show this at all.
The $args parameter (array) is also completely optional ( i.e. NOT required ). It can be passed in as an array of options: overriding some or all of these defaults:
"before_widget" => "" HTML code to display before the widget.
"before_title" => "<h3>" HTML code to display before the title.
"after_title" => "</h3>" HTML code to display after the title.
"after_widget" => "" HTML code to display after the widget.

This allows you to add options and arguments to your login code in the functions.php file like so:

<?php
add_shortcode('my-login-shortcode','my_login_shortcode');

function my_login_shortcode(){

	$options = array("login_redirect" => "%%previous%%",
				"display_gravatar" => "1");
				
	return s2member_pro_login_widget($options);
	
}
?>

Hope that helps,

Dave

Posted: Thursday Jun 7th, 2012 at 8:46 pm #15874
Jim Climy
Username: weasel

Dumb question but then how could you add the login as a menu item then?

Posted: Friday Jun 8th, 2012 at 8:20 pm #15997
Raam Dev
Username: Raam
Staff Member

Jim,

You could add a menu item manually by editing your theme’s header.php file, or if your theme supports custom menus you can do it through Appearance -> Menus, and point the link to your login page (e.g., /wp-login.php).

Posted: Monday Jun 11th, 2012 at 5:38 pm #16157
David Welch
Username: dwbiz05

@Jim Climy

Are you looking to just link to the page where you put the link shortcode, or are you trying to add the login form inline in your menu bar?

Dave

Posted: Monday Jun 11th, 2012 at 5:40 pm #16158
Jim Climy
Username: weasel

Ideally a popup or similar that allows you to login from the menu, but I guess a link to a login form is OK.

Posted: Tuesday Jun 12th, 2012 at 8:44 am #16241
David Welch
Username: dwbiz05

I just found this trick and it may not be the best way to do this but I think it will work.

I’m going to assume you know how to create a modal popup (suggest jquery).

Steps:
1. add a page to your menu… wherever you want the login link to be. you can use any page, it doesn’t matter.
2. save the menu
3. expand the new menu item you added (there are now new attribute options).
4. add a specific class name to that item, like login_modal or something unique.
5. add similar code to what’s below in your header or main .js file if there is one (in you document onready function).

$('.login_modal').click(function(){ //adding an onclick function to the class login_modal
	alert('testing'); //you would replace this with your js or jquery pop-up modal box
	return false; //keep this to ensure the page doesn't actually go anywhere.
	});

Make sure you add the “return false;” so it doesn’t try to follow the actual link.

The problem with this is that it’s javascript so if someone has it turned off, then it will follow the link. I would suggest creating a page with the login widget as it’s content, then using that page to link to. That way if the user’s JS isn’t working or turned on, it still sends them to a login screen. You should be able to do the same by using the http://yoursite.com/wp-login.php instead of creating a page, if you want.

Hope that helps,
Dave

Posted: Thursday Jun 21st, 2012 at 1:40 pm #17142
Jim Climy
Username: weasel

Unfortunately I don’t know how to add a modal popup. Is this what this website has? Seems to have a popup login form that comes up when I am logged out and click “login” in top left?

Viewing 8 replies - 1 through 8 (of 8 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.