PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Custom Header Output?

s2Member Plugin. A Membership plugin for WordPress®.

Custom Header Output?

Postby AlxRam » May 4th, 2011, 7:59 pm

I'm just getting started installing s2member and everything looks great. I'd like to hack the information that gets output to the header. I see two files (a css and javascript) associated with s2member and I only need them to show up on the single and page templates. I already have custom header templates for each.

So basically I'm looking for an example of how to:

1. Remove s2member css and javascript using functions.php
2. Then add s2member css and javascript to 2 template files only

I don't know if it's possible that way... any other suggestions would also be appreciated.

Thanks :)
User avatar
AlxRam
Registered User
Registered User
 
Posts: 20
Joined: May 2, 2011

Re: Custom Header Output?

Postby AlxRam » May 4th, 2011, 8:02 pm

Silly me. I just realized I can take the code from the source view and copy it to my template files. Now all I have to do is remove them using functions.php

I see the code example for removing the css:
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");

Can I use a similar action to remove the javascript file?
User avatar
AlxRam
Registered User
Registered User
 
Posts: 20
Joined: May 2, 2011

Re: Custom Header Output?

Postby Cristián Lávaque » May 4th, 2011, 8:12 pm

From the FAQs http://www.s2member.com/support/

How can I prevent s2Member Pro from loading it's default CSS?

You can place this into the functions.php file for your WordPress® theme.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
 


Or, you could remove only specific action Hooks; based on Payment Gateway.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_alipay_css_js::alipay_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_authnet_css_js::authnet_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_ccbill_css_js::ccbill_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_clickbank_css_js::clickbank_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_google_css_js::google_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_paypal_css_js::paypal_css");
 


I haven't tried it, but it's probable that it'll work for JavaScript if you change the css at the end for js. Let me know if it works. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Custom Header Output?

Postby AlxRam » May 4th, 2011, 8:23 pm

Cristián Lávaque wrote:From the FAQs http://www.s2member.com/support/

How can I prevent s2Member Pro from loading it's default CSS?

You can place this into the functions.php file for your WordPress® theme.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
 


Or, you could remove only specific action Hooks; based on Payment Gateway.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_alipay_css_js::alipay_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_authnet_css_js::authnet_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_ccbill_css_js::ccbill_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_clickbank_css_js::clickbank_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_google_css_js::google_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_paypal_css_js::paypal_css");
 


I haven't tried it, but it's probable that it'll work for JavaScript if you change the css at the end for js. Let me know if it works. :)


Hmmm, strange. That code isn't removing either from the header. I'll keep playing with it some more and see if I can find the problem... this is what I put in functions.php

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::js");


Also tried with apostrophes instead of quotes like this:

Code: Select all
remove_action ('ws_plugin__s2member_during_css', 'c_ws_plugin__s2member_pro_css_js::css');
remove_action ('ws_plugin__s2member_during_css', 'c_ws_plugin__s2member_pro_css_js::js');
User avatar
AlxRam
Registered User
Registered User
 
Posts: 20
Joined: May 2, 2011

Re: Custom Header Output?

Postby Jason Caldwell » May 4th, 2011, 10:05 pm

This will work, but you'll need to remove the Hooks, only after they've been added. Sorry, I should have included this in the documentation too. Please follow these updated instructions.

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
Code: Select all
<?php
add_action 
("ws_plugin__s2member_after_loaded", "remove_s2_pro_css");
function remove_s2_pro_css ()
    {
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
    }
?>
* This works for CSS only. You can't do this with s2Member's JS file, it would break Pro Form functionality and other areas of s2Member as well. The JavaScript library is required to operate s2Member.


If you'd like to ONLY remove the CSS for specific
Payment Gateway integrations, you can do it like this instead.
Code: Select all
<?php
add_action 
("ws_plugin__s2member_after_loaded", "remove_s2_pro_css");
function remove_s2_pro_css ()
    {
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_alipay_css_js::alipay_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_authnet_css_js::authnet_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_ccbill_css_js::ccbill_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_clickbank_css_js::clickbank_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_google_css_js::google_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_paypal_css_js::paypal_css");
    }
?>

@TODO: update the official documentation to make this clear.
100% Completed ( coming in the next release )
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Custom Header Output?

Postby AlxRam » May 4th, 2011, 10:53 pm

Odd. That plugin file isn't working either or I'm missing something with that. I uploaded it to /wp-content/mu-plugins/s2-hacks.php but there are no new plugins on my plugins page, and the header css is still there.

10-4 on the .js file being needed. I think I'll just leave both as-is as it's not crucial for me, I just like to run header info on the pages that need it only (as much as possible).

Thanks again for your help Jason :)
User avatar
AlxRam
Registered User
Registered User
 
Posts: 20
Joined: May 2, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron