Page 1 of 1

Pro Login Widget via PHP tag

PostPosted: March 15th, 2011, 7:21 pm
by jacksonmurphy
I can't get this to work?

I insert this code:

Code: Select all
<?php echo s2member_pro_login_widget(); ?>


And nothing shows up?
Any ideas why this wouldn't work?

Re: Pro Login Widget via PHP tag

PostPosted: March 15th, 2011, 7:38 pm
by Cristián Lávaque
Do you have s2Member Pro?

You'll also need this plugin http://wordpress.org/extend/plugins/php ... on-plugin/ for PHP to work in your posts.

Hope that helps. :)

Re: Pro Login Widget via PHP tag

PostPosted: March 16th, 2011, 9:14 am
by jacksonmurphy
Hey Cristian-
Thanks for your response.
I do have s2Member Pro...
I am putting the php code inside a custom template... not inside a post or page.

Re: Pro Login Widget via PHP tag

PostPosted: March 16th, 2011, 11:28 am
by Cristián Lávaque
OK, good. :)

Would you post between code tags the code of the template file with the login widget that's not showing up? Like this:

[code=php]Your template file code[/code]

Re: Pro Login Widget via PHP tag

PostPosted: March 16th, 2011, 11:51 am
by jacksonmurphy
You can view the test page here:
http://www.annawilson.com/pr-kit-test/

If I can get this widget to show, I want to be able to redirect the user back to this page... where they can view the content... once logged in (see code below)

This is what I currently have in my template:

Code: Select all

<?php
/**
 * Template Name: Presskit Test
 */
 
?>
 
<?php get_header(); ?>

    <!-- The class "grid_7" restricts the div to 7 columns wide -->
    <div id="content" class="grid_10 prefix_1">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
        
            <div class="entry">
                
                <?php echo s2member_pro_login_widget(); ?> 

            </div><!-- end entry -->
            
        </div><!-- end post -->
        
        <?php endwhile; endif; ?>
        <?php edit_post_link('Edit this entry.''<p>''</p>'); ?>
        <br />
    </div><!-- end content -->

    <div id="sidebar" class="grid_4">
    
    </div>

<?php get_footer(); ?>


This is what I'm trying to do:

Code: Select all

<?php if (is_user_logged_in() && current_user_can("access_s2member_ccap_presskit")) { ?>
                
                    <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
                
                <?php } else { ?>
                
                    <h1>Members of the Press Only</h1>
                    Please login to view this page.
                    <?php echo s2member_pro_login_widget(); ?>
                
                <?php ?> 

Re: Pro Login Widget via PHP tag

PostPosted: March 16th, 2011, 12:36 pm
by Cristián Lávaque
Yes, I see widget missing in the HTML, and you're doing it the way the documentation says. I'll ask Jason about it.

Regarding what you're trying to do, that should be fine. Since you're doing most of that in PHP, there's no real need to get in and out of PHP all the time, you could do it like this:

Code: Select all
<?php if (is_user_logged_in() && current_user_can('access_s2member_ccap_presskit'))
    the_content('<p class="serif">Read the rest of this page &raquo;</p>');
else
    echo '<h1>Members of the Press Only</h1> Please login to view this page.', s2member_pro_login_widget(); ?>

Re: Pro Login Widget via PHP tag

PostPosted: March 16th, 2011, 6:38 pm
by jacksonmurphy
Thanks Cristian! I very much appreciate all your help!

Re: Pro Login Widget via PHP tag

PostPosted: March 16th, 2011, 7:29 pm
by Cristián Lávaque
You are welcome. :)

Re: Pro Login Widget via PHP tag

PostPosted: March 17th, 2011, 8:55 am
by jacksonmurphy
Would it have anything to do with PHP settings on the server?
http://www.annawilson.com/test.php

Re: Pro Login Widget via PHP tag

PostPosted: March 18th, 2011, 7:56 pm
by Jason Caldwell
Thanks for reporting your experience with s2Member.
~ and thank you Cristián for bringing this to my attention.
jacksonmurphy wrote:Would it have anything to do with PHP settings on the server?
http://www.annawilson.com/test.php

To answer this question. No, I doubt that it has anything to do with PHP configuration.

I've just been over this entire thread and I took a quick look at your test page. I'm sorry, there's nothing jumping right out at me. Everything here looks as if it should be working. My "best guess" at this point, is that your test page is actually NOT using that Page Template you're working from. Is it possible that you have another Page Template that creates similar output; and thus, is creating some confusion?

If this problem continues, please send an email to support with a Dashboard login.

Re: Pro Login Widget via PHP tag

PostPosted: March 18th, 2011, 9:51 pm
by jacksonmurphy
Hey Jason
I appreciate you taking time to help solve my issue here...
I'll email support...

But to make sure that the test page is using the correct template, I put some text in the template...
Also added the Login Widget to the sidebar...

http://www.annawilson.com/pr-kit-test/

Code: Select all

<?php
/**
 * Template Name: Presskit-Test
 */
 
?>
 
 <?php get_header(); ?>



    <!-- The class "grid_7" restricts the div to 7 columns wide -->
    <div id="content" class="grid_10 prefix_1">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
        
            <div class="entry">
                
                This is Presskit-Test Template:<br /><br />
                
                The login widget should show up here:<br />
                
               <?php echo s2member_pro_login_widget(); ?>


            </div><!-- end entry -->
            
        </div><!-- end post -->
        
        <?php endwhile; endif; ?>
        <?php edit_post_link('Edit this entry.''<p>''</p>'); ?>
        <br />
    </div><!-- end content -->

    <div id="sidebar" class="grid_4">
    <?php
    
if ( ! dynamic_sidebar'press-widget' ) ) : ?>
    <?php endif; // end primary widget area ?><br />
    </div>


<?php get_footer(); ?>

Re: Pro Login Widget via PHP tag

PostPosted: March 22nd, 2011, 11:03 pm
by Jason Caldwell
After an inspection of this bug in a live environment, we've discovered that the mysterious problem reported here, has to do with some versions of PHP not dealing with call_user_func_array() on a non-static member function. This is going to be corrected in the maintenance release of s2Member v3.5.6. Thanks for your assistance in this matter!

Re: Pro Login Widget via PHP tag

PostPosted: March 23rd, 2011, 7:00 am
by jacksonmurphy
Thanks for helping resolve this! I appreciate it

Re: Pro Login Widget via PHP tag

PostPosted: March 23rd, 2011, 7:22 pm
by Cristián Lávaque
Thank you for helping find it! :)