Page 1 of 1

Embed a Login Form ?

PostPosted: October 4th, 2011, 8:37 pm
by barefootango
Hi,

I know this has been asked before, but I have yet to find a suitable answer.

Im running WP 3.2.1 and the latest version of S2 Pro.

How would one embed a login form.

I have tried this, but this code throws an error in the middle of this insert:

<?php echo s2member_pro_login_widget(array('title' => 'Membership Login', 'signup_url' => 'http://barefootango.com/wp-login.php?action=register')); ?>

The error being that it sees everything after the first > sign as just text and doesn't enact the code on the line.

Anyone ????

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 12:52 am
by barefootango
Update: I found a way to embed the form, there are a number of plugins that will allow you to embed php code into a page or a post. One such is "ALLOW PHP CODE IN POSTS", works like a charm, and the form that I'm calling is coming up. I understand, now, that those array values above in my original post are in fact variables that I can change, great! Which are being pulled from the s2member_pro_login_widget() api (http://bit.ly/nuGl2O)!

One such value: "before_widget" => "" allows you to post HTML directly before the widget runs.

So right now, my code looks like:

[php]
echo s2member_pro_login_widget(array("before_widget" => "echo '<table width=300><tr><td align=center'>", 'title' => 'Membership Login', 'signup_url' => 'http://xxxxxxxxxx.com/wp-login.php?action=register', "after_widget" => "echo '</tr></td></table>'"));
[/php]

The page runs without errors, but it also strangely enough IGNORES the HTML before AND after!

Anyone care to jump in here ????

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 1:37 am
by beetle
hi,

this works for me:

Code: Select all
function ls_business_login_widget() {
    $options = array(
        "title" => "Business Account Login",         // Title when NOT logged in, or leave this blank if you'd prefer not to show a title.
    "signup_url" => "/business/sign-up/",          // Full Signup URL, or use %%automatic%% for the Membership Options Page. If you leave this blank, it will not be shown.
    "login_redirect" => "/my-account/",                   // 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" => "",  // Title when a User is logged in. Or you can leave this blank if you'd prefer not to show a title.
    "display_gravatar" => "0",                // Display Gravatar image when logged in? 1 = yes, 0 = no. Gravatars are based on email address.
    "link_gravatar" => "0",                   // 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" => "%%previous%%",          // 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" => "/my-business-profile"      //  Full URL of your own, or use %%automatic%% for a JavaScript popup. Leave empty to not show this at all.
    );
    $args = array (
        "before_widget" => "<div class=\"bus_login_widget\">",
        "after_widget" => "</div>",
        "before_title" => "<h5>",
        "after_title" => "</h5>"
    );
    echo s2member_pro_login_widget($options, $args);
}
 


i'm pretty sure i grabbed the code from the s2member docs somewhere...

beetle :)

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 1:40 am
by beetle
aaaah - and its from the s2member plugin in wordpress dashboard here:
s2Member -> API Scripting -> Pro Login Widget via PHP

beetle :)

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:25 am
by Cristián Lávaque
Thanks for your help, beetle. :)

barefootango wrote:[php]
echo s2member_pro_login_widget(array("before_widget" => "echo '<table width=300><tr><td align=center'>", 'title' => 'Membership Login', 'signup_url' => 'http://xxxxxxxxxx.com/wp-login.php?action=register', "after_widget" => "echo '</tr></td></table>'"));
[/php]

The page runs without errors, but it also strangely enough IGNORES the HTML before AND after!


Try without the echo in the HTML strings.

Code: Select all
echo s2member_pro_login_widget(array('before_widget' => '<table width=300><tr><td align=center>', 'title' => 'Membership Login', 'signup_url' => 'http://xxxxxxxxxx.com/wp-login.php?action=register', 'after_widget' => '</tr></td></table>')); 


I hope that helps.

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:30 am
by beetle
Hi,

moving from private -> public messages in case this helps others... the way cristian suggests in the previous reply is how i suggest you do it instead.... and its how you were trying to do it i think originally...

the way i do it is - wordpress theme loads all my code (including function), created a login page that calls my function, function spits out the login form into page...

the way I suggest you do it is - create a new "Login" page and copy/paste this into it:
Code: Select all
<?php

    $options 
= array(
        "title" => "Membership Account Login",         
    
"signup_url" => "/sign-up/",          
    
"login_redirect" => "",          
    
"profile_title" => "",  
    
"display_gravatar" => "0",                
    
"link_gravatar" => "0",                  
    
"display_name" => "1",                   
    
"logged_in_code" => "",                  
    
"logout_redirect" => "%%previous%%",         
    
"my_account_url" => "%%automatic%%",      
    
"my_profile_url" => "/my-membership-profile"      
    
);
    $args = array (
        "before_widget" => "<div class=\"member_login_widget\">",
        "after_widget" => "</div>",
        "before_title" => "<h5>",
        "after_title" => "</h5>"
    );
    echo s2member_pro_login_widget($options, $args);
?>


hope that works for you - if not cristian may have fixed your code above :)

beetle :)

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:36 am
by barefootango
Ok, Now I know I really screwed this up.

I wanted this to appear in a PAGE that already existed!

Im not looking to create a new login page, Im trying to embed a login form inside an existing wp page.

from the admin section of wordpress pages > add new > ... create a new page.

Now I want to embed a login form into THAT new page...not a php page.

Capice ?

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:38 am
by beetle
Hi,

you can embed that into any existing wp page - between text or where ever you want! wordpress will execute the php code as long as you've got a php-executing plugin enabled which I assumed you had??

if not add the plugin: PHP Execution

this will let you dump php straight into wp pages and it will execute fine... that might have been your problem all along then...

beetle :)

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:41 am
by beetle
Hi again,

once you've got it working - make sure you update the different options so they suit you - that code has pointers to my sign-up url etc... check out the s2member docs in wordpress dashboard here for what options do what!
s2Member -> API Scripting -> Pro Login Widget via PHP

beetle :)

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:50 am
by barefootango
Beetle,

No I had that working just fine before, I had already surmised that I needed a plug-in to allow for me to dump it into the page, which is what I was describing in my earlier post of OOOPS!.

That said, this:

<?php
function ls_business_login_widget() {
$options = array(
"title" => "Member Login",
"signup_url" => "http://xxxxxxxxxxxxxx.com/wp-login.php?action=register"
);
$args = array (
"before_widget" => "<table width=\"300\"><tr><td>",
"after_widget" => "</td></tr></table>"
);
echo s2member_pro_login_widget($options, $args);
}
?>

IS NOT WORKING.

What am I doing wrong ???

Miles.

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:55 am
by beetle
that's the old code - the function - which would work if you called the function straight afterwards... try just using the code as per above message:


<?php

$options = array(
"title" => "Membership Account Login",
"signup_url" => "/sign-up/",
"login_redirect" => "",
"profile_title" => "",
"display_gravatar" => "0",
"link_gravatar" => "0",
"display_name" => "1",
"logged_in_code" => "",
"logout_redirect" => "%%previous%%",
"my_account_url" => "%%automatic%%",
"my_profile_url" => "/my-membership-profile"
);
$args = array (
"before_widget" => "<div class=\"member_login_widget\">",
"after_widget" => "</div>",
"before_title" => "<h5>",
"after_title" => "</h5>"
);
echo s2member_pro_login_widget($options, $args);
?>

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 2:57 am
by beetle
as per your code you could do either:

<?php
function ls_business_login_widget() {
$options = array(
"title" => "Member Login",
"signup_url" => "http://xxxxxxxxxxxxxx.com/wp-login.php?action=register"
);
$args = array (
"before_widget" => "<table width=\"300\"><tr><td>",
"after_widget" => "</td></tr></table>"
);
echo s2member_pro_login_widget($options, $args);
}

ls_business_login_widget();

?>

OR use the code itself you pasted:

<?php
$options = array(
"title" => "Member Login",
"signup_url" => "http://xxxxxxxxxxxxxx.com/wp-login.php?action=register"
);
$args = array (
"before_widget" => "<table width=\"300\"><tr><td>",
"after_widget" => "</td></tr></table>"
);
echo s2member_pro_login_widget($options, $args);

?>

what you are currently doing is just defining a function.... that is never called :)

beetle :)

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 3:20 am
by barefootango
Ok, I finally got it working....sort of!

Sort of in this case means that the form is up, but I had that working the first time around.

The problem was and still is that I can't modify the form, without affecting the widget on the same page!

(see attachment)

So I figured by importing the form to the page, and then surrounding it in a table statement would do the trick, it does, it just looks UGLY when I do that, because then it creates line artifacts where there was none before. So I backed off that, and now its adding more space to the form and adding double <BR> where there wasn't any before....lord knows what the hell is happening anymore....

Ok if that makes any sense to you folks, is there a solution where by I can reduce the size of this embedded form and put it smack dab in the center of this page, and it doesn't appear all ugly like it is now without any line artifacts ?

Miles.

PastedGraphic-4.png

Re: Embed a Login Form ?

PostPosted: October 5th, 2011, 4:00 am
by beetle
Hi Miles,

Sorry - i don't understand the question - if you're talking about the width of the membership login form in the page itself you can just surround it with a div using

"before_widget" => "<div class=\"member_login_widget\">",
"after_widget" => "</div>",

and either add styling to the div itself above OR add to your css specifications for your "member_login_widget" class

are you familiar with css?

i may be completely misunderstanding the issue?

beetle

Re: Embed a Login Form ?

PostPosted: October 6th, 2011, 2:00 am
by barefootango
Thanks everyone got it all working!