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.

David Welch


My Latest Replies (From Various Topics)

Viewing 25 replies - 76 through 100 (of 407 total)
Author Replies
Author Replies
Posted: Wednesday Sep 26th, 2012 at 1:30 pm #26605
David Welch
Username: dwbiz05

Ok, so it looks like this form is created by a class function and not a template in s2member.

So, one option would be to copy the code BETWEEN:

<?php
/**
* Shortcode for `[s2Member-Profile /]` ( inner processing routines ).
*
* Copyright: © 2009-2011
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
* ( coded in the USA )
*
* Released under the terms of the GNU General Public License.
* You should have received a copy of the GNU General Public License,
* along with this software. In the main directory, see: /licensing/
* If not, see: {@link http://www.gnu.org/licenses/}.
*
* @package s2Member\Profiles
* @since 3.5
*/
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
	exit ("Do not access this file directly.");
/**/
if (!class_exists ("c_ws_plugin__s2member_sc_profile_in"))
	{
		/**
		* Shortcode for `[s2Member-Profile /]` ( inner processing routines ).
		*
		* @package s2Member\Profiles
		* @since 3.5
		*/
		class c_ws_plugin__s2member_sc_profile_in
			{
				/**
				* Handles the Shortcode for: `[s2Member-Profile /]`.
				*
				* @package s2Member\Profiles
				* @since 3.5
				*
				* @attaches-to ``add_shortcode("s2Member-Profile");``
				*
				* @param array $attr An array of Attributes.
				* @param str $content Content inside the Shortcode.
				* @param str $shortcode The actual Shortcode name itself.
				* @return str|null The resulting Profile Modifiation Form *( inline )*, or null if not logged-in.
				*/
				public static function sc_profile ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
				{
					eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
					do_action ("ws_plugin__s2member_before_sc_profile", get_defined_vars ());
					unset ($__refs, $__v); /* Unset defined __refs, __v. */

AND:

}
		}
	}
?>

in this file:

wp-content/plugins/s2member/includes/classes/sc-profile-in.inc.php

Then create your own function in wp-content/mu-plugins/s2-hacks.php (you may need to create this directory and file) like this:

<?php
add_action('ws_plugin__s2member_before_sc_profile','my_profile_form');

function my_profile_form(){
	//Copy the code mentioned above here and change it to look the way you want.
	//See example below:
	
	//leaving php
	?>
	<form action="" method="post">
	My Name: <input >
	</form>
	<?
	//back to php
	
	exit(); // this exit function keeps the rest of their code in that class from running.
}
?>

That should override their form with yours. Assuming you keep their functionality and stuff, I think it should still work fine.

Hope that helps.

Dave

PS. This is not perfect because it uses the exit() function which kills all the rest of the processing and could mess up other s2 functions being called at the same time.

  • This reply was modified 4 years, 3 months ago by  David Welch.
Posted: Wednesday Sep 26th, 2012 at 12:59 pm #26598
David Welch
Username: dwbiz05

I would set it to:

Required: No
Allow Profile Edits : Yes (Editable)

Add this in the Other Attributes (optional) Section:

onclick="var urlCheck = window.location + ''; if(urlCheck.indexOf('wp-admin') == '-1'){ $(this).attr('disabled','disabled'); }"

This should disable the field if the user clicks on it but should allow the admin to edit it in the admin section.

Not sure about Editor Level access. You may have to use a role editor plugin to add that functionality.

Hope that helps,

Dave

Posted: Wednesday Sep 26th, 2012 at 12:17 pm #26588
David Welch
Username: dwbiz05

wrap the content with this shortcode:

[s2If current_user_is(s2member_level2)]
    Some premium content for Level 2 Members.
[/s2If]
[s2If !current_user_is(s2member_level2)]
    You do not have access to this page.
[/s2If]

if you use “current_user_can(access_s2member_level2)” then anyone at or above that level will see it.

The above function says they must BE at that level.

That should do it.

Dave

PS. or you could use CCaps. However, I think if you use CCaps, it will send them to the membership options page if they don’t have that CCap. (not sure) Which you may or may not want, depending on the type of site you are building.

  • This reply was modified 4 years, 3 months ago by  David Welch.
  • This reply was modified 4 years, 3 months ago by  David Welch.
  • This reply was modified 4 years, 3 months ago by  David Welch.
  • This reply was modified 4 years, 3 months ago by  David Welch.
Posted: Wednesday Sep 26th, 2012 at 12:12 pm #26584
David Welch
Username: dwbiz05

Another thing you could do…

Create different membership forms / buttons, some that are full memberships and some that are 3 weeks.

Then add Custom Capability codes to your product pages based on the package they are part of. (package_1, package_2, etc.)

Add all the CC codes to the forms for regular memberships, and then just one CC code for each of the 3 week memberships or however you plan to sell them.

That’s probably the easiest way to do it… you just have to update all your pages with different CC based on the product they are attached to.

I always think of the hard way first… lol

Dave

  • This reply was modified 4 years, 3 months ago by  David Welch.
Posted: Wednesday Sep 26th, 2012 at 12:08 pm #26583
David Welch
Username: dwbiz05

There is no “Easy” way to do this.

My suggestion would be to work it like this:

Sell Custom Capabilities for each “product.”

Update your product pages to check if the user is a member at X level OR has the CC that was purchased.

Then update your membership options page to list both memberships and individual trial access to the products with CC buttons.

The biggest issue is that CC’s are lifetime access. So you would need to hook into the payment processing, store the time when it is purchased in a user meta field, then check that field when the user attempts to access it to see if it has been more than 3 weeks since the time that is stored as the purchase date.

Simple right? lol

The easiest thing would be to sell access to specifict posts / pages. However, that doesn’t play well with pages that are already protected via a membership level per the S2member documentation.

I think this can be done but it’s going to take some work and some technical know-how.

Dave

Posted: Wednesday Sep 26th, 2012 at 11:42 am #26577
David Welch
Username: dwbiz05

All paid registration times for each level are stored in the same user meta variable called “wp_s2member_paid_registration_times”. This is a serialized array of all registration times for that user.

That function you are using should be working. If not, try this one. It should call the same info being called by that function:

<?php
//Get level paid reg time

function dw_paid_level_time($level=1,$user_id=S2MEMBER_CURRENT_USER_ID){

	$time = get_user_meta($user_id,'wp_s2member_paid_registration_times',true); //gets usermeta data
	
	if(isset($time['level'.$level])){
		return $time['level'.$level]; //returns timestamp of designated level
	}
	else {
		return 0; //returns 0 if not found.
	}
}
?>

Call the above function like this:

<?php $level_1_reg_time = dw_paid_level_time(1); //attributes call level number first then user_id if not current user. ?>

Hope that helps,

Dave

  • This reply was modified 4 years, 3 months ago by  David Welch.
Posted: Wednesday Sep 26th, 2012 at 11:24 am #26575
David Welch
Username: dwbiz05

I haven’t looked at that template, but if it uses the same css layout and html structure for the form elements, I don’t see why it wouldn’t.

Dave

Posted: Monday Sep 24th, 2012 at 1:45 am #26262
David Welch
Username: dwbiz05

Any reason why you wouldn’t just use multiple levels instead of 1 level with different purchase amounts?

With Pro you can create as many levels as you want. Then just use the example in the s2member guides for adding your protected downloads.

Then just create your paypal buttons, one for each level with the payment amount you want for that level.

Hope that helps.

Dave

Posted: Monday Sep 24th, 2012 at 1:32 am #26261
David Welch
Username: dwbiz05

Have you tried adding the captcha to your forms to see if that makes a difference? That’s where I would start. Other than that, I’m not sure how they could be registering.

Dave

Posted: Monday Sep 24th, 2012 at 1:29 am #26260
David Welch
Username: dwbiz05

If you are using the Pro version under Paypal or any other gateway should be a “free” option for registration shortcodes.

So, under Paypal Pro Forms => Paypal Pro / Free Registration Forms is probably what you are looking for.

NOTE: I’ve not used s2member with an MU set-up so I’m just assuming you have the option… lol.

Dave

Posted: Monday Sep 24th, 2012 at 1:26 am #26259
David Welch
Username: dwbiz05

Are you sure that this is pulling the registration timestamp?

What do you get when you echo $level2_payment_time?

Not trying to make you feel silly just trying to get all the info to help trouble shoot. The reason I ask is because if they have not paid, it would return a 0… which is less than the timestamp of 1 day ago. Which means it would show the content.

You’ve tested this on with a different user’s account that is at that specific level or has paid for it?

Dave

Posted: Thursday Sep 20th, 2012 at 2:35 pm #25982
David Welch
Username: dwbiz05

One issue is that everywhere s2member prints a commented code:

<!-- with something here -->

wordpress is adding paragraph tags to them, which increase the space used.

I’m not sure why it’s doing that, but you might try something like this to keep them from affecting your spacing:

#s2member-pro-authnet-checkout-form p { display: none; }

Hope that helps some. I might check on it later to see if there are other suggestions.

Dave

Posted: Thursday Sep 20th, 2012 at 11:24 am #25961
David Welch
Username: dwbiz05

ah, gracias

Posted: Thursday Sep 20th, 2012 at 8:15 am #25924
David Welch
Username: dwbiz05

I agree with Janet, Custom Capabilities is the easiest way to grant access to any member at any level for any thing.

Dave

Posted: Thursday Sep 20th, 2012 at 8:07 am #25922
David Welch
Username: dwbiz05

Thanks, I’m actually ignoring free users for this function. My biggest concern is making sure it gets fired if the free user uses an update form. I guess I’ll just have to test it out.

Dave

Posted: Thursday Sep 20th, 2012 at 12:35 am #25880
David Welch
Username: dwbiz05

My first thought is that you don’t have a plugin that allows you to put php code into your wordpress pages.

See, wordpress does not natively parse php code that is put into the page editor, even if it’s in the “html” side.

You need a plugin that will force wordpress to parse the php code in your button form so it will enter the correct data.

Probably the most common, and the one recommended by S2member is http://wordpress.org/extend/plugins/php-execution-plugin/

You can also find it by searching in the new plugins section of wordpress for “php execution.”

That should solve the problem, unless you already have it installed and it’s still not working.

Hope that helps,

Dave

Posted: Wednesday Sep 19th, 2012 at 11:35 pm #25876
David Welch
Username: dwbiz05

I think this is what you are looking for. It’s under the “shortcode attributes (explained)” section:

rrt=”” Recurring Times ( i.e. a fixed number of installments ). Only valid w/ Membership Level Access. When unspecified, any recurring charges will remain ongoing until cancelled, or until payments start failing. If this is set to 1 or higher the regular recurring charges will only continue for X billing cycles, depending on what you specify. This is only valid when rr=”1″ for recurring “Subscriptions”. Please note that a fixed number of installments, also means a fixed period of access. If a Customer’s billing is monthly, and you set rrt=”3″, billing will continue for only 3 monthly installments. After that, billing would stop, and their access to the site would be revoked as well ( based on your EOT Behavior setting under: s2Member -> Authorize.Net® Options ).

Hope that helps,

Dave

Posted: Wednesday Sep 19th, 2012 at 6:07 pm #25860
David Welch
Username: dwbiz05

Just took a look at your site… I think you accidentally commented out your own code…

/*********** Salesforce Form - Page ***********\

/*********** Salesforce Form - Sidebar ***********\

/*********** S2 Member Pro Forms ***********\

Should be

/*********** Salesforce Form - Page ***********/

/*********** Salesforce Form - Sidebar ***********/

/*********** S2 Member Pro Forms ***********/

See if that fixes your issue.

Dave

Posted: Wednesday Sep 19th, 2012 at 5:48 pm #25859
David Welch
Username: dwbiz05

Could you re-add that code and wrap it with the “code” or “code w/hilite” tags (green buttons, far left)?

I think just pasting it in is messing it up and making some of it unreadable.

Dave

Posted: Wednesday Sep 19th, 2012 at 5:40 pm #25858
David Welch
Username: dwbiz05

*NOTE: You should only use this function if you have a legal copy of s2member pro. Much of this code was copied from the s2member files.

I created a quick little class that you can put in an mu-plugin to add some of this functionality. It’s not perfect but it seems to work for me when I use it this way. Again, I have not done extensive testing on this function.

Step 1 -> Create a directory / file in this location:

http://yourdomain.com/wp-content/mu-plugins/s2-hacks.php

Step 2 -> Add this code to that file (s2-hacks.php):

<?php
//Dave Welch - Custom Fields In Custom Template Class

class DW_custom_template {
	public static function get_s2_custom_field($id,$level=0){
		
		$_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST));
		/*
		Obtain a possible response and/or validation error.
		*/
		$response = c_ws_plugin__s2member_pro_paypal_responses::paypal_registration_response($attr);
		/*
		Empty post vars on successful response.
		*/
		$_p = ($response["response"] && !$response["error"]) ? array(): $_p;
		
		$custom_field_array = json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true);
	
		foreach($custom_field_array as $k => $v){
			if($v['id'] == $id){
				$id_key = $k;
				break;
			}
		}
		
		//print_r($custom_field_array);
		
		$fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level($level, "registration");
		$custom_fields = '';
		$field = $custom_field_array[$id_key];
		if(!empty($custom_field_array)){
			if(isset($field['id']) && $field['id'] == $id){
				if(in_array($field["id"], $fields_applicable))//Field is applicable to Level 0? 
				{
					$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
					$field_id_class = preg_replace("/_/", "-", $field_var);
					
					if(!empty($field["section"]) && $field["section"] === "yes") // Starts a new section? 
						$custom_fields .= '<div id="s2member-pro-paypal-registration-form-custom-reg-field-'.$field_id_class.'-divider-section" class="s2member-pro-paypal-form-div s2member-pro-paypal-registration-form-div s2member-pro-paypal-form-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').' s2member-pro-paypal-form-custom-reg-field-'.$field_id_class.'-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').' s2member-pro-paypal-registration-form-custom-reg-field-'.$field_id_class.'-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>';
					
					$custom_fields .= '<div id="s2member-pro-paypal-registration-form-custom-reg-field-'.$field_id_class.'-div" class="s2member-pro-paypal-form-div s2member-pro-paypal-registration-form-div s2member-pro-paypal-form-custom-reg-field-'.$field_id_class.'-div s2member-pro-paypal-registration-form-custom-reg-field-'.$field_id_class.'-div">'."\n";
				
					$custom_fields .= '<label for="s2member-pro-paypal-registration-custom-reg-field-'.esc_attr($field_id_class).'" id="s2member-pro-paypal-registration-form-custom-reg-field-'.$field_id_class.'-label" class="s2member-pro-paypal-form-custom-reg-field-'.$field_id_class.'-label s2member-pro-paypal-registration-form-custom-reg-field-'.$field_id_class.'-label">'."\n";
					$custom_fields .= '<span'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '').'>'.$field["label"].(($field["required"] === "yes") ? ' *' : '').'</span></label>'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />')."\n";
					$custom_fields .= c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "s2member_pro_paypal_registration[custom_fields][", "s2member-pro-paypal-registration-custom-reg-field-", "s2member-pro-paypal-custom-reg-field-".$field_id_class." s2member-pro-paypal-registration-custom-reg-field-".$field_id_class, "", ($tabindex = $tabindex + 1), "", $_p, $_p["s2member_pro_paypal_registration"]["custom_fields"][$field_var], "registration");
					
					$custom_fields .= '</div>'."\n";
					
					return $custom_fields;
				}
				else {
					return 'Not Applicable Field';
				}
			}
			else {
				return 'Invalid ID';
			}
		}
		else {
			return 'No Custom Fields';
		}
	}
}
?>

Step 3 -> Place this line of code in your template where you want your custom field to be. You will use the Unique ID for that field to call it.

<?php echo DW_custom_template::get_s2_custom_field('your-field-id-here'); ?>

If you have any questions, let me know. If it doesn’t work let me know too.. again this has been tested very little. lol

Hope it helps,

Dave

Posted: Wednesday Sep 19th, 2012 at 4:23 pm #25853
David Welch
Username: dwbiz05

ok, so it looks like Payflow might use some different variables… of course.. lol.

You might try this if you aren’t getting any success with the other one:

//Function our hook above will call.
function change_error_36($bool,$vars=array()){
	if(isset($vars["response"]["L_ERRORCODE0"])){
		//PayPal Variables
		
		$vars['response']['__error'] = "PayPal sent the following error:<br>Error #".$vars["response"]["L_ERRORCODE0"].": ".$vars["response"]["L_SHORTMESSAGE0"]." - ".$vars["response"]["L_LONGMESSAGE0"]; //Change the text in the quotes to the left to change the message.
	
		//Sending the response variable back to the s2member function.
		return $vars["response"];
	}
	else if(isset($vars["response"]["TRXRESULT"])){
		//Payflow Variables - I think
		
		$vars['response']['__error'] = "PayPal sent the following error:<br>Error #".$vars["response"]["TRXRESULT"].": ".$vars["response"]["TRXRESPMSG"]; //Change the text in the quotes to the left to change the message.
	
		//Sending the response variable back to the s2member function.
		return $vars["response"];
	}
}

Hope that helps,

Dave

Posted: Wednesday Sep 19th, 2012 at 4:13 pm #25850
David Welch
Username: dwbiz05

It stands for Must Use Plugins.

Here is a link to a very detailed page on the wordpress codex:

http://codex.wordpress.org/Must_Use_Plugins

S2member uses a function called apply_filters();

This searches for any “add_filter()” functions created by any plugin or mu-plugin that calls it’s specific “tag.”

Wordpress handles all of this in the background. But as long as you add_filter() using the same tag that S2member used, you can “break in” to the s2member processes without messing with their original code. (good for updates)

Dave

  • This reply was modified 4 years, 3 months ago by  David Welch.
Posted: Wednesday Sep 19th, 2012 at 4:10 pm #25849
David Welch
Username: dwbiz05

Another issue is that in order to program for a specific code, you have to know which code it is that is being thrown. Which means you won’t know ahead of time what to filter until it happens to a user.

One option would be to not filter the message code and just print it out with an explanation that the processor sent it, like this function below:

//Function our hook above will call.
function change_error_36($bool,$vars=array()){
	$vars['response']['__error'] = "PayPal sent the following error:<br>Error #".$vars["response"]["L_ERRORCODE0"].": ".$vars["response"]["L_SHORTMESSAGE0"]." - ".$vars["response"]["L_LONGMESSAGE0"]; //Change the text in the quotes to the left to change the message.
	
	//Sending the response variable back to the s2member function.
	return $vars["response"];
}

This would return:

PayPal sent the following error:
Error #36: Transaction failed - Fail to obtain approval for the online transaction.

Hope that makes sense.

Dave

Posted: Wednesday Sep 19th, 2012 at 3:55 pm #25847
David Welch
Username: dwbiz05

OK Folks…

Here is the deal. These messages are a compilation of multiple pieces from the payment processor(s).

Of course they all send different variables, so S2member handles each one individually instead of with one function… lol

The short answer is, yes you can change the message. The long answer is that it will take some “programming.”

If you don’t have this directory/file, make it now:

yourdomain.com/wp-content/mu-plugins/s2-hacks.php

Now, in this file (s2-hacks.php), let’s put the following code:

<?php
//Dave Welch - Filter CC Error Message #36

//Hook Into the filter where this error is processed.
add_filter('ws_plugin__s2member_paypal_api_response','change_error_36',10,2);

//Function our hook above will call.
function change_error_36($bool,$vars=array()){

	//Checking to see if the response code is #36.
	if(isset($vars["response"]["L_ERRORCODE0"]) && $vars["response"]["L_ERRORCODE0"] == 36){
	
		//If it is #36, we are changing the error message here.
		$vars['response']['__error'] = "Your New Message Here."; //Change the text in the quotes to the left to change the message.
	}

	//Sending the response variable back to the s2member function.
	return $vars["response"];
}
?>

Now, that *should* hook into the process and change the message. The issue is that this function is only set up to work with Paypal (not sure it that includes pro).

If I get time later tonight, I’ll see if I can put together a switch function to handle more than one payment type. I don’t use Paypal, but I tested it with Auth.net and this solution worked for me.

Hope that helps and let me know if you have any questions.

Dave

Posted: Wednesday Sep 19th, 2012 at 1:46 pm #25835
David Welch
Username: dwbiz05

I believe this message may actually come from the processor, not S2 but I’m not 100% sure. I’ve seen the code for this but I’ll have to look it back up.

What payment option are you using?

Dave

Viewing 25 replies - 76 through 100 (of 407 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.