cwjordan
Forum Replies Created
-
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Field "Telephone number"Since phone number formats vary regionally I am not sure how you would best add them to the plugin, still it’s a useful feature I’d like to see.
I don’t know much javascript, but it looks like you are using the “modernizr” library which should make it safe to use the html5 input “pattern” feature?
Your code is nicely laid out, it was not a problem to add another type, so I edited your plugin to add a phone number field, with the US phone number pattern (123-456-7890). The bit from bp-xprofile-custom-fields-type.php with the pattern check in it looks like this:
<input type="tel" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true" required="required"<?php endif; ?> class="input" value="<?php echo bp_the_profile_field_edit_value(); ?>" pattern="\d{3}[\-]\d{3}[\-]\d{4}" placeholder="<?php _e('123-456-7890', 'bxcfg'); ?>" />
I haven’t done much testing with it yet, but it seems to work okay.
I did not mark this as resolved.
Note I had the same problem with 1.31.2 and applied the same fix.
Oh, I got this too. It means your version of PHP is too old. I was running PHP 5.2 and I had to upgrade to PHP 5.3 to fix it. Google says that “anonymous functions are only supported on 5.3+”.
Now, given that PHP 5.2 is supported by WordPress still, I think there should at least be a warning in the Pie-Register release notes about the required PHP version changing with version 1.30 of Pie-Register.
After I updated from wordpress 3.4.2 to wordpress 3.5.1 the password strength meter broke again. The problem is pie-register.php is looking for password-strength-meter.dev.js which is not there in WordPress 3.5.1, it is password-strength-meter.js instead. After I changed that name in pie-register.php it worked again.
Chip_88 I changed the pie-register.php script so that where it had paths like:
wp-includes/js/jquery/jquery.js?ver=1.2.3
I changed them to start one directory higher like so:
../wp-includes/js/jquery/jquery.js?ver=1.2.3
I believe that will break if Theme My Login is _not_ installed, so that’s not a good general solution. I’m not sure what the best thing to do is. Here is the complete diff between the original pie-register.php script in Pie Register version 1.2.9a, and my customized version (this also has a fix for https support):
$ diff pie-register.php pie-register.php.orig 46,47c46 < /* cwjordan - we want plugin_url to be https if needed so use "plugins_url()" */ < $this->plugin_url = trailingslashit(plugins_url(basename(dirname(__FILE__)))); --- > $this->plugin_url = trailingslashit(get_option('siteurl')) . 'wp-content/plugins/' . basename(dirname(__FILE__)) .'/'; 247,262c246,256 < if (is_array($rpg)) { < foreach ($rpg as $k=>$v) { < $rpg[$k] = $this->disable_magic_quotes_gpc($v); < } < } else { < if (TRUE == function_exists('get_magic_quotes_gpc') && 1 == get_magic_quotes_gpc()){ < $mqs = strtolower(ini_get('magic_quotes_sybase')); < < if (TRUE == empty($mqs) || 'off' == $mqs){ < // we need to do stripslashes on $_GET, $_POST and $_COOKIE < $rpg=stripslashes($rpg); < } < else{ < // we need to do str_replace("''", "'", ...) on $_GET, $_POST, $_COOKIE < $rpg=str_replace("''","'",$rpg); < } --- > $drf=$rpg; > if (TRUE == function_exists('get_magic_quotes_gpc') && 1 == get_magic_quotes_gpc()){ > $mqs = strtolower(ini_get('magic_quotes_sybase')); > > if (TRUE == empty($mqs) || 'off' == $mqs){ > // we need to do stripslashes on $_GET, $_POST and $_COOKIE > $rpg=stripslashes($rpg); > } > else{ > // we need to do str_replace("''", "'", ...) on $_GET, $_POST, $_COOKIE > $rpg=str_replace("''","'",$rpg); 264c258 } --- > } 265a260 > //return $drf; 1441c1436 < <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>../wp-includes/js/jquery/jquery.js?ver=1.7.1'></script> --- > <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>wp-includes/js/jquery/jquery.js?ver=1.7.1'></script> 1449c1444 < <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>../wp-includes/js/jquery/jquery.color.js?ver=2.0-4561'></script> --- > <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>wp-includes/js/jquery/jquery.color.js?ver=2.0-4561'></script> 1461c1456 < <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>../wp-admin/js/password-strength-meter.dev.js?ver=20070405'></script> --- > <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>wp-admin/js/password-strength-meter.dev.js?ver=20070405'></script> 1689c1684 < <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>../wp-includes/js/jquery/jquery.js?ver=1.2.3'></script> --- > <script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>wp-includes/js/jquery/jquery.js?ver=1.2.3'></script> 2092c2087 < ?> --- > ?>
Thanks Jeff. I did not mean to imply that TML is doing something wrong, just that what it does doesn’t work with what Pie Register is doing, if Pie Register is configured to use the password strength meter.
Pie Register and TML both affect the login page, so perhaps conflicts are to be expected? I don’t know enough about plugin design to say what should be happening here. My change to the pie-register.php script works for me but would fail in the general case.
I found the answer to this problem at the plugin’s website: https://www.pie-solutions.com/products/pie-register – look back a few pages in the comments for the one by jonhartling. Basically the error message means there is nothing set for Required Profile fields in the database, which is because in some cases Pie Register doesn’t save that properly. It’s weird, because it works okay on my test server at home, but not on my production server. Anyway, jonhartling’s fix works for me, and I will repeat it here:
Edit pie-register.php and change the section for “function disable_magic_quotes_gpc($rpg)” to:
function disable_magic_quotes_gpc($rpg){ if (is_array($rpg)) { foreach ($rpg as $k=>$v) { $rpg[$k] = $this->disable_magic_quotes_gpc($v); } } else { if (TRUE == function_exists('get_magic_quotes_gpc') && 1 == get_magic_quotes_gpc()){ $mqs = strtolower(ini_get('magic_quotes_sybase')); if (TRUE == empty($mqs) || 'off' == $mqs){ // we need to do stripslashes on $_GET, $_POST and $_COOKIE $rpg=stripslashes($rpg); } else{ // we need to do str_replace("''", "'", ...) on $_GET, $_POST, $_COOKIE $rpg=str_replace("''","'",$rpg); } } } return $rpg; }