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.

add a algorithm in custom field

Home Forums Community Forum add a algorithm in custom field

This topic contains 8 replies, has 2 voices. Last updated by  Eduan 3 years, 10 months ago.

Topic Author Topic
Posted: Wednesday Dec 26th, 2012 at 4:17 am #35494

hello I would like to add a field in my form by inserting a key calculation.
I add the field and selected numerical characters but I do not know how to add this algorithm.
cordially

List Of Topic Replies

Viewing 8 replies - 1 through 8 (of 8 total)
Author Replies
Author Replies
Posted: Wednesday Jan 23rd, 2013 at 3:06 am #39125

Up please

Posted: Thursday Jan 24th, 2013 at 10:46 pm #39475
Eduan
Username: Eduan
Moderator

Hello Antoine,

I’m afraid that to add this you would have to do it custom coded, you cannot do this with s2Member, you would have to add it in other words, through code of course.

– Eduan

Posted: Friday Jan 25th, 2013 at 3:14 am #39486

Hi Eduan,

Thank you for your answer, I know what I’m asking is to be custom made, I must create the file via code-s2 hacks.php him even located in the mu-plugins. I’ve also seen videos explaining how jason insert the code, I did a test with the same example as him but I think my code is not called.

Here is the code in my file-s2 hacks.php

<?php

add_action("ws_plugin__s2member_before_custom_field_gen", "my_dynamic_field_options");
function my_dynamic_field_options($vars = array())
	{
		$_field = &$vars[$__refs][$_field];
		
		if ($_field["id"] === "country_code")
		{
			$_field["options"] = "US|United States|default" . "\n";
			$_field["options"] .= "CA|canada" . "\n";
			$_field["options"] .= "VI|Virgin Islands (U.S.)";
		}
	}
?>
Posted: Monday Feb 18th, 2013 at 8:47 am #42250

Hello
I’m still on the same problem and I have the impression that the file-s2 hacks.php does not take into account the conditions.
I created a log file to see if the page took proper account of the actions I was doing and after several changes the page doesn’t take into account the conditions.

<?php

	add_action("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", "my_dynamic_field_options");
	add_filter("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", "my_dynamic_field_options2");

	function my_dynamic_field_options($vars = Array()){
		$_field = &$vars[$__refs][$field];
		
		if($_field["id"] === "country_code"){
			$_field["options"] = "US|United States|default" . "\n";
			$_field["options"] = "CA|canada" . "\n";
			$_field["options"] = "VI|Virgin Islands (U.S.)";
			
			$monfichier = fopen('compteur.txt', 'r+');
			$pages_vues = fgets($monfichier); // On lit la première ligne (nombre de pages vues)
			fseek($monfichier, 0); // On remet le curseur au début du fichier
			$pages_vues++; // On augmente de 1 ce nombre de pages vues
			fputs($monfichier, $pages_vues); // On écrit le nouveau nombre de pages vues
			fclose($monfichier);
		}
		
		
		/*$_field = &$vars[$__refs][$field];
		if($_field["type"] === "text"){
			$monfichier = fopen('compteur.txt', 'r+');
			$pages_vues = fgets($monfichier); // On lit la première ligne (nombre de pages vues)
			fseek($monfichier, 0); // On remet le curseur au début du fichier
			$pages_vues++; // On augmente de 1 ce nombre de pages vues
			fputs($monfichier, $pages_vues); // On écrit le nouveau nombre de pages vues
			fclose($monfichier);
		}*/
		
	}
?>

Help me please

Posted: Monday Feb 18th, 2013 at 9:30 am #42256
Eduan
Username: Eduan
Moderator

I’m afraid I can’t provide any help Antoine. :/
I’m pretty much a newbie when it comes to the code side of WordPress.

Perhaps you could hire a freelancer to check the code and fix it for you? At websites like jobs.wordpress.net or elance.com for example.

– Eduan

Posted: Monday Feb 18th, 2013 at 10:39 am #42271

thank you for your response Eduan I’ll head to the sites proposed and continue to fiddle my code (I’m fine finish not find)

Posted: Monday Feb 18th, 2013 at 11:29 am #42276

After several tests I realized my mistake came from my :

$_field = &$vars[$__refs][$field];

who did not take the $ declaration of my table entries.
I continued my research hoping to find soon

Posted: Monday Feb 18th, 2013 at 12:03 pm #42286
Eduan
Username: Eduan
Moderator

Excellent! Glad you figured it out Antoine! :)

Viewing 8 replies - 1 through 8 (of 8 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

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.