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.

Home Forums Hamid

Hamid


My Latest Replies (From Various Topics)

Viewing 25 replies - 26 through 50 (of 61 total)
Author Replies
Author Replies
Posted: Sunday Oct 14th, 2012 at 1:42 pm #28385
Hamid
Username: zawiyaprojects

OK I think this one did it :)

The modified working code is

function s2hack_membership_options_vars( $atts ){
 if(isset($_GET['_s2member_seeking'])) # We need to display something
 {
        $s2_seeking = $_GET['_s2member_seeking']; # Content user was trying to access
        $s2_level   = $_GET['_s2member_req'];     # What was needed to access said content]

        if(!empty($s2_seeking['page']))
                $content = 'page';
        elseif (!empty($s2_seeking['post']))
                $content = 'post';
        if(!empty($s2_level['level']))
                $req = $s2_level['level'];
                        if ($req=='1')
                           $s2_label='a Plus';
                        elseif ($req=='2')
                           $s2_label='a Premier';
        else
                $s2_label = 'at least a free';

        return '<strong>Sorry, this ' . $content . ' is restricted. You need ' . $s2_label . ' subscription in order to access it.</strong>';
 }
 else
        return; # We don't need to do anything, no variables passed.
}
add_shortcode( 'membership_options_vars', 's2hack_membership_options_vars' );
Posted: Sunday Oct 14th, 2012 at 1:28 pm #28384
Hamid
Username: zawiyaprojects

Well not quite.

The displayed message “Sorry, this page is restricted. You need a Plus subscription to access it.” appears whether the page’s access level is set to level 1 or level 2.

What am I doing wrong?

Posted: Sunday Oct 14th, 2012 at 1:21 pm #28383
Hamid
Username: zawiyaprojects

OK I think I got it to work but I’m not 100% about the syntax.

function s2hack_membership_options_vars( $atts ){
 if(isset($_GET['_s2member_seeking'])) # We need to display something
 {
        $s2_seeking = $_GET['_s2member_seeking']; # Content user was trying to access
        $s2_level   = $_GET['_s2member_req'];     # What was needed to access said content]

        if(!empty($s2_seeking['page']))
                $content = 'page';
        elseif (!empty($s2_seeking['post']))
                $content = 'post';
        if(!empty($s2_level['level']))
                $req = $s2_level['level'];
                        if ($req='1')
                           $s2_label = 'a Plus';
                        elseif ($req = '2')
                           $s2_label = 'a Premier';
        else
                $req = 'at least a free ';

        return '<strong>Sorry, this ' . $content . ' is restricted. You need ' . $s2_label . ' subscription  to access it.</strong>';
 }
 else
        return; # We don't need to do anything, no variables passed.
}
add_shortcode( 'membership_options_vars', 's2hack_membership_options_vars' );
Posted: Wednesday Oct 10th, 2012 at 5:37 am #27967
Hamid
Username: zawiyaprojects

Hello Support and other s2member users,

After reading up on other coding examples and the s2member documentation, I ended up using an alternate solution which I think is much better, less coding and the user won’t have to go through two step process to get to Paypal’s payment page. It also resolves a formatting issue I was having with the Paypal button, but that may be related to my theme.

PREREQUISITE: If you offer an annual Level 1 membership and you want to automatically calculate the amount a user would have to pay to upgrade to an annual Level 2 membership.

WHAT IT DOES: Calculates a Level 1 user’s PAID REGISTRATION DAYS which is then subtracted from 365 and then multiplied with the daily rate of that subscription. This figure is the user’s credit amount toward Level 2 subscription. The prorated rate (for upgrading to Level 2) is calculated by subtracting this credit amount from the Level 2 subscription fee. It shows the prorated fee to only Level 1 members. For free subscribers it shows a link for each of the paid subscriptions.

WHERE IT GOES: You can place the code below in your members options page or a separate page that you members can call up.

<?php
$PlusFee = 49.95; // Enter subscription fee for Level 1 membership 
$PremFee = 79.95; // Enter subscription fee for Level 2 membership
$PlusDailyRate = .13685; // Enter daily rate based on level 1 subscription fee divided by 365
$PlusCredit = ((365 - S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS) * $PlusDailyRate);
$PremCharges = $PremFee - $PlusCredit; 
$PremCharges = round($PremCharges,2); //round off number to 2 decimal points
?>

<?php
if (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 1){ ?>
	<?php if(S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 0){ ?>
<a href="[s2Member-PayPal-Button level="2" ccaps="" desc="Prorated Upgrade from Plus to Premier membership for one year for $<?php echo esc_attr($PremCharges); ?>" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="your.domain.com" ta="0" tp="0" tt="D" ra="<?php echo esc_attr($PremCharges); ?>" rp="1" rt="Y" rr="0" rrt="" rra="1" image="default" output="url" /]">Upgrade to Premier for only $<?php echo esc_attr($PremCharges); ?>!</a>
	<?php } ?>
	
<?php } elseif (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 0){ ?>
<a href="[s2Member-PayPal-Button level="1" ccaps="" desc="Plus membership for one year access, non-recurring (one time charge)" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="your.domain.com" ta="0" tp="0" tt="D" ra="49.95" rp="1" rt="Y" rr="0" rrt="" rra="1" image="default" output="url" /]">Upgrade to Plus member today!</a>
or
<a href="[s2Member-PayPal-Button level="2" ccaps="" desc="Premier membership for one year with automatic yearly recurring charges for ongoing access." ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="your.domain.com" ta="0" tp="0" tt="D" ra="79.95" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="url" /]">Upgrade to Premier status for immediate access to over 4000 audio files!</a>
<?php } ?>

NOTE: output=”url” if you want to use text instead of the Paypal image.

I’m now working on including my own “Buy Now!” image instead of the text. Just thought to share just in case someone else was looking to do the same :)

Posted: Tuesday Oct 9th, 2012 at 11:54 am #27902
Hamid
Username: zawiyaprojects

Please disregard last question, I got it.

Posted: Tuesday Oct 9th, 2012 at 9:03 am #27890
Hamid
Username: zawiyaprojects

Update:

Everything seems to work well using the above example and I was able to upgrade via Paypal. Thanks for the help :)

I have a separate question:

How do I actually display the number of S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS. What code would I use to display the actual number of days in a subscription?

Posted: Tuesday Oct 9th, 2012 at 7:13 am #27885
Hamid
Username: zawiyaprojects

OK it works now. I had to turn off “Enable Button Encryption?” under the Paypal Options >> Paypal Account Details

Posted: Tuesday Oct 9th, 2012 at 6:56 am #27878
Hamid
Username: zawiyaprojects

Hey Raam, here is the actual code in the member profile page contain the elseif statements

... <?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 0){ ?>
<a href="http://www.domain.com/member-options/?amount=27.45">Upgrade to Premier for only $27.45</a>...
	

And here is the Paypal button short code in the member options page

[s2Member-PayPal-Button level="2" ccaps="" desc="Prorated Upgrade to Premier Member" 
ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="www.domain.com" ta="0" tp="0" tt="D" 
ra="<?php echo esc_attr($_GET["amount"]); ?>" rp="1" rt="Y" rr="BN" rrt="" rra="1" 
image="default" output="button" /]
  • This reply was modified 4 years, 3 months ago by  Hamid.
Posted: Monday Oct 8th, 2012 at 11:45 pm #27842
Hamid
Username: zawiyaprojects

It all seems to work up until I click on the Paypal button. When redirected to Paypal, I get the following error:

We were unable to decrypt the certificate id.
Posted: Monday Oct 8th, 2012 at 2:49 pm #27821
Hamid
Username: zawiyaprojects

OK, it worked after setting the EOT date and changing the >=1 to >=0

What did you mean about changing the elseif to else?

Posted: Monday Oct 8th, 2012 at 2:42 pm #27820
Hamid
Username: zawiyaprojects

Nope, didn’t work :(

If I created a user via the dashboard and assigned them level 1, does it automatically assign them expiration date? And based on the code above, I will need to wait at least one day, correct?

Posted: Monday Oct 8th, 2012 at 2:09 pm #27815
Hamid
Username: zawiyaprojects

Eduan, I see what you mean now with the content dripping part. Thanks.

Would this be proper syntax then?

<?php if (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 1){ ?>
	<?php if(S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 330){ ?>
		http://www.domain.com/membership-options-page/?amount=77.50
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 300){ ?>
		http://www.domain.com/membership-options-page/?amount=72.95
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 270){ ?>
		http://www.domain.com/membership-options-page/?amount=68.40
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 240){ ?>
		http://www.domain.com/membership-options-page/?amount=63.85
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 210){ ?>
		http://www.domain.com/membership-options-page/?amount=59.30
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 180){ ?>
		http://www.domain.com/membership-options-page/?amount=54.75
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 150){ ?>
		http://www.domain.com/membership-options-page/?amount=50.20
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 120){ ?>
		http://www.domain.com/membership-options-page/?amount=45.65
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 90){ ?>
		http://www.domain.com/membership-options-page/?amount=41.10
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 60){ ?>
		http://www.domain.com/membership-options-page/?amount=36.55
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 30){ ?>
		http://www.domain.com/membership-options-page/?amount=32.00        
	<?php } elseif (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 1){ ?>
		http://www.domain.com/membership-options-page/?amount=27.45
	<?php } ?>
<?php } else if (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 0){ ?>
    	Upgrade to Plus or Premier membership.
<?php } ?>
Posted: Monday Oct 8th, 2012 at 1:35 pm #27810
Hamid
Username: zawiyaprojects

Thanks Eduan for the tips…

I’m getting ready to read up on the content dripping link you provided. My understanding of content dripping was offering content on a timed basis. I didn’t know you could offer upgrades with it though. Thanks again.

Posted: Monday Oct 8th, 2012 at 11:58 am #27804
Hamid
Username: zawiyaprojects

Hello Simeon, did you ever get an answer. I was wondering the exact same thing using ccaps.

I don’t think it is something that can be changed based on the different memberships one may offer but rather set globally to the membership “level”.

I’m hoping they changed this in the next major release :) hint hint

Posted: Sunday Sep 30th, 2012 at 4:55 am #27002
Hamid
Username: zawiyaprojects

I have include the javascript part here for anyone else trying to do this. Please keep in mind it’s very generic at the moment and only a starting point (to proceed you will need to get the proper billing data field ids).

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>

<h3>Billing Fields</h3>
  <div>Street Adress: <input type="text" id="billingStreet"/></div>
  <div>City/Town: <input type="text" id="billingCity"/></div>  
  <div>State/Province:<input type="text" id="billingState"/></div>
  <div>Country:<input type="text" id="billingCountry"/></div> 
  <div>Zip:<input type="text" id="billingZip"/></div>  
 
 
  
<h3>Custom Fields</h3>    
  <div>Custom Street Address:<input type="text" id="customStreet"/></div>
  <div>Custom City/Town:<input type="text" id="customCity"/></div>  
  <div>Custom State/Province:<input type="text" id="customState"/></div>  
  <div>Country:<input type="text" id="customCountry"/></div> 
  <div>Zip:<input type="text" id="customZip"/></div>  
  
  
<script>
  window.onload = function () {
  	var billingStreet = document.getElementById('billingStreet'),
    customStreet = document.getElementById('customStreet');

	var billingCity = document.getElementById('billingCity'),
	customCity = document.getElementById('customCity');
	
	var billingState = document.getElementById('billingState'),
	customState = document.getElementById('customState');

	var billingCountry = document.getElementById('billingCountry'),
	customCountry = document.getElementById('customCountry');
	
	var billingZip = document.getElementById('billingZip'),
	customZip = document.getElementById('customZip');	

	// can use either billingStreet.onkeyup or billingStreet.onchange 
  	billingStreet.onkeyup = function () { 
    customStreet.value = billingStreet.value;
    };

  	billingCity.onkeyup = function () { 
    customCity.value = billingCity.value;
    };    
 
  	billingState.onkeyup = function () { 
    customState.value = billingState.value;
    };  

  	billingCountry.onkeyup = function () { 
    customCountry.value = billingCountry.value;
    };    
 
  	billingZip.onkeyup = function () { 
    customZip.value = billingZip.value;
    }; 
    
};
</script>
</body>
</html>
Posted: Sunday Sep 30th, 2012 at 4:45 am #27001
Hamid
Username: zawiyaprojects

Raam, I worked out the javascript part to fill out the billing and custom fields. But I will have to wait until the next major release of s2member as I currently have a Paypal Advanced account (not Pro).

Posted: Thursday Sep 27th, 2012 at 6:43 am #26668
Hamid
Username: zawiyaprojects

Thanks Raam,

I’m working on it now. Will let you know what happens.

Posted: Friday Sep 7th, 2012 at 10:56 am #24530
Hamid
Username: zawiyaprojects

Thanks Eduan,

OK I see that now. So I would have to do it for each user via the dashboard.

Is there a way to do it with a SQL statement? Something like “update cc with private where user id=1, 2, 3”.

Sorry about the syntax, I don’t know SQL very well but couldn’t I run a query that updates all the userids that I would like to give the “private” custom capability to?

Posted: Thursday Aug 2nd, 2012 at 6:52 am #20989
Hamid
Username: zawiyaprojects

OK, I found it. Please disregard the last question.

It’s in the s2member login widget :)

Posted: Thursday Aug 2nd, 2012 at 6:05 am #20986
Hamid
Username: zawiyaprojects

Thanks Raam

I was able to edit the profile template :)

On another note, I remember seeing an option where you could set the “Edit my profile” link to automatic or to another page (if I remember correctly), but I cant seem to find where that is now, even though I have gone through all of s2member options.

After a user logs in, they can either click on “My account”, “Edit My Profile” or “Logout”. I would like to redirect the “Edit My Profile” link to a custom wordpress page (that has the profile shortcode embedded in it). Currently when you click on the link it brings up a pop-up window to http://www.domain.com/?s2member_profile=1. I would like to change it to my wordpress page (http://www.domain.com/edit-profile/)

Thanks

Posted: Sunday Jul 15th, 2012 at 3:55 am #19283
Hamid
Username: zawiyaprojects

Oh I forgot to add this. I’m not sure if this was an issue but in any case…

5.) The crossdomain.xml in my bucket was empty so I re-uploaded it with the following data:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*" />
</cross-domain-policy>
Posted: Sunday Jul 15th, 2012 at 3:38 am #19282
Hamid
Username: zawiyaprojects

OK, I admit it. I’m an idiot!!!

I finally got it to work, hurray :)

Here is what I did.

1.) I entered 999999 in ALL the fields for “Basic Download Restrictions” even though I’m only using member level 0 and 1 (at the moment)
2.) Although it still works with the comments included, I striped all the comment from the “JW Player® & RTMP Protocol Examples” code in order to simplify things just in case I was overlooking something, which I was.
3.) I didn’t see that there are TWO [script type=”text/javascript”] sections. I had only placed the “raw” tag around the first one.
4.) I humble myself before you guys. Soooooo sorry for being such a dolt and thanks for all your help, comments and patience in getting me thru this :)

I have supplied my modified example code for other to see. Please note, that you may not be able to edit your page after publishing it the first time due to the (raw) tags. When I edited the page after publishing it, it would break again, I believe because of the (raw) tags redoing its thing on the already modified code.

Please Note: I used parenthesis () instead of brackets [] around the raw tag due to the posting restriction of this forum. If you use the code below, make sure to change the raw tags to include brackets (and not parenthesis as displayed below).

<?php
$s2_jw_config["jwplayer"] = "/jwplayer/";
$s2_jw_config["mp4_video_file_name"] = "reviews/20120427_Review_10.50-55.mp4";
?>

<div id="jw-container">JW Player® appears here.</div>
(raw)<script type="text/javascript" src="<?php echo $s2_jw_config["jwplayer"]; ?>jwplayer.js"></script>(/raw)

<?php
$cfg = array ("file_download" => $s2_jw_config["mp4_video_file_name"], "url_to_storage_source" => true, "count_against_user" => true); 
?>

<?php
if (($mp4 = s2member_file_download_url ($cfg, "get-streamer-array"))) { 
?>

    (raw)
    <script type="text/javascript">
        jwplayer("jw-container").setup({modes: /* JW Player®. */
        [
            {type: "flash", provider: "rtmp", src: "<?php echo $s2_jw_config["jwplayer"]; ?>player.swf",
                config: {streamer: "<?php echo $mp4["streamer"]; ?>", file: "<?php echo $mp4["file"]; ?>"}},
        
            {type: "html5", provider: "video",
                config: {file: "<?php echo $mp4["url"]; ?>"}},
        
            {type: "download",
                config: {file: "<?php echo $mp4["url"]; ?>"}}
        ],
        width: 640, height: 395
        });
    </script>
    (/raw)

<?php } else { ?>
    Sorry, you do NOT have access to this file.
<?php } ?> 

Thanks everyone… now on to the next mountain mole hill :)

Posted: Saturday Jul 14th, 2012 at 10:47 am #19255
Hamid
Username: zawiyaprojects

Issue Resolved with Cloudfront :)

I’m not quite sure which of the two resolved it but…

1.) I deleted all my Amazon key pairs and recreated new keys.
2.) I noticed that when I copied and pasted the key pairs into the s2member fields that some fields would have a space at the end of the string. I made sure to remove the spaces.

Now back to JWPlayer… still shows “JW Player® appears here.”

I can access the player.swf if I point my browser to http://www.domain.com/jwplayer/ so Im not sure why it cant find it thru s2member/wordpress.

Posted: Saturday Jul 14th, 2012 at 8:27 am #19245
Hamid
Username: zawiyaprojects

Hey Raam,

Yes I allowed s2member to auto configure the distributions and it said it was set up correctly.

The distros were created and I could see them via my AWS console. I have deleted and recreated the download and streaming distros a few time now, all with the same results :(

I have deleted them again for now as I’m not sure what the problem could be, although I am able to download via my s3 bucket (as long as cloudfront isnt configured).

Has anyone else seen this before?

Posted: Saturday Jul 14th, 2012 at 12:44 am #19203
Hamid
Username: zawiyaprojects

Hello Bob, thanks for the suggestion.

I’ve been trying to resolve s3 and cloudfront since I’ve installed s2member. I’m going nuts…

I ended up reinstalling WordPress and s2member with very few plugins activated. Here are my results:

If I only use s3 (without cloudfront), I am able to download my files using example shortcode and links such as:

<a href="[s2File download="20120504_Review_10.54-58.mp4" /]">Download Now</a>

<a href="[s2File download="20120504_Review_10.54-58.mp4" inline="false" /]">Download Now - Not Inline</a>

<a href="<?php echo s2member_file_download_url(array("file_download" => "20120504_Review_10.54-58.mp4", file_download_key => true)); ?>">Download Now with Key</a>

<a href="[s2File download="20120504_Review_10.54-58.mp4" download_key="true" /]">Download</a>

The moment I add cloudfront, the above links all fail with the following error (even after creating new keys):

AccessDeniedAccess denied

Anyone have any ideas why?

P.S. JWPlayer still doesn’t work for me but will get to that later after resolving my Cloudfront issue.

Viewing 25 replies - 26 through 50 (of 61 total)

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.