Giter VIP home page Giter VIP logo

pmpro-register-helper's Introduction

=== PMPro Register Helper === Contributors: strangerstudios Tags: users, user meta, meta, memberships, registration Requires at least: 3.5 Tested up to: 4.0.1 Stable tag: .5.19

Add extra fields to your checkout page. Works with Paid Memberships Pro.

== Description == This plugin currently requires Paid Memberships Pro.

== Installation ==

  1. Upload the pmpro-register-helper directory to the /wp-content/plugins/ directory of your site.
  2. Activate the plugin through the 'Plugins' menu in WordPress.

Add a sign up form to a post/widget/page using a shortcode:

[pmpro_signup level="3" short="1" intro="0" button="Signup Now"]

Adding a field to your checkout page requires two steps: (1) create a field object, (2) call pmprorh_add_registration_field() to add the field to the checkout page. Optionally, you can create your own "checkout_box" or fieldset to the checkout page using pmprorh_add_checkout_box().

e.g.

$text = new PMProRH_Field("company", "text", array("size"=>40, "class"=>"company", "profile"=>true, "required"=>true));
pmprorh_add_registration_field("after_billing_fields", $text);

The first parameter of the pmprorh_add_registration_field designates where the field will show up. Here are the current options:

  • after_username
  • after_password
  • after_email
  • after_captcha
  • checkout_boxes
  • after_billing_fields
  • before_submit_button
  • just_profile (make sure you set the profile attr of the field to true or admins)

NOTE: The first parameter of the PMProRH_Field function must contain no spaces or special characters other than _ or -.

Here are some examples of fields:

//company field is required and editable by admins and users in the profile page
$text = new PMProRH_Field("company", "text", array("size"=>40, "class"=>"company", "profile"=>true, "required"=>true));
	
//referral id is not required and only editable by admins. Includes an updated label.
$referral = new PMProRH_Field("referral", "text", array("label"=>"Referral Code", "profile"=>"admins"));
	
//dropdown, includes a blank option
$dropdown = new PMProRH_Field("gender", "select", array("options"=>array("" => "", "male"=>"Male", "female"=>"Female")));
	
//select2 dropdown
$select2 = new PMProRH_Field("category", "select2", array("profile"=>"only", "required"=>true, "options"=>array("cat1"=>"Category 1", "cat2"=>"Category 2", "cat3"=>"Category 3"), "select2options"=>"maximumSelectionSize: 2"));  

//radio
$radio = new PMProRH_Field("gender", "radio", array("options"=>array("male"=>"Male", "female"=>"Female"))); 

//checkbox
$checkbox = new PMProRH_Field("agree", "checkbox", array("profile"=>true));

//textarea
$history = new PMProRH_Field("history", "textarea", array("rows"=>10, "label"=>"Tell us a little about your history."));
	
//hidden
$secret = new PMProRH_Field("secret", "hidden", array("value"=>"this is the secret"));

//any html
$html = new PMProRH_Field("htmlsection", "html", array("html"=>"<p>You can put any HTML here, and it will be <strong>added</strong> to your form.</p>"));

//readonly field
$readonly = new PMProRH_Field("r1", "readonly", array("value"=>"Readonly value"));

//readonly property on other field type
$readonly_text = new PMProRH_Field("r2", "text", array("value"=>"Readonly value", "readonly"=>true));

//file uploads
$resume = new PMProRH_Field("resume", "file", array("profile"=>true, "options"=>array()));

//Dependent fields. Add a "depends" value to the params array. Value should be an array of arrays. The inner array should be of the form array("id"=>{field id}, "value"=>{field value})
$category = new PMProRH_Field("category", "select", array("options"=>array("cat1"=>"Category 1", "cat2"=>"Category 2")));  
$subcat1 = new PMProRH_Field("subcat", "select", array("options"=>array(1=>"Subcat 1.1", 2=>"Subcat 1.2", 3=>"Subcat 1.3"), "depends"=>array(array("id"=>"category", "value"=>"cat1"))));  
$subcat2 = new PMProRH_Field("subcat", "select", array("options"=>array(1=>"Subcat 2.1", 2=>"Subcat 2.2", 3=>"Subcat 2.3"), "depends"=>array(array("id"=>"category", "value"=>"cat2"))));

In can be helpful to store the fields in an array use a loop to add the fields. e.g.

$fields = array();
$fields[] = new PMProRH_Field("company", "text", array("size"=>40, "class"=>"company", "profile"=>true, "required"=>true));
$fields[] = new PMProRH_Field("referral", "text", array("label"=>"Referral Code", "profile"=>"admins"));
$fields[] = new PMProRH_Field("gender", "select", array("options"=>array("" => "", "male"=>"Male", "female"=>"Female")));
foreach($fields as $field)
	pmprorh_add_registration_field("checkout_boxes", $field);

Adding a checkout box.

pmprorh_add_checkout_box("personal", "Personal Information");	//order parameter defaults to one more than the last checkout box
pmprorh_add_checkout_box("business", "Business Information", "Fields below are optional but will help us in verifying your account.");

Then add fields to these boxes.

$field = new PMProRH_Field("gender", "select", array("options"=>array("" => "", "male"=>"Male", "female"=>"Female")));
pmprorh_add_registration_field("personal", $field);

$field = PMProRH_Field("company", "text", array("size"=>40, "class"=>"company", "profile"=>true, "required"=>true));
pmprorh_add_registration_field("business", $field);

Note that the "checkout_boxes" location is now just the first checkout_box in the list with order = 0.

== Frequently Asked Questions ==

= I found a bug in the plugin. =

Please post it in the issues section of GitHub and we'll fix it as soon as we can. Thanks for helping. https://github.com/strangerstudios/pmpro-register-helper/issues

== Changelog == = .5.19 =

  • Can now set the "showrequired" option to "label" (all lower) and the required asterisk will be rendered between the label and the input field. Useful for some themes/designs.
  • Fixed warning in pmprorh_cron_delete_tmp(). (Thanks, nozzljohn)

= .5.18 =

  • Added code to set the enctype on the edit user page so file uploads work in the admin.

= .5.17.3 =

  • Fixed warning on radio and readonly fields when shown in the profile. (Thanks, MarkG)

= .5.17.2 =

  • The "depends" functionality now supports checking select2 and multiselect fields. The depending field will show up if any of the selected values in the multiselect equals the value given. e.g. "depends"=>array(array("id"=>"category", "value"=>"category1")) will show the depending field if category1 is one of the options selected in the #category multiselect field. (Thanks, Erik Bertrand)

= .5.17.1 =

  • Fixed fatal error that would occur sometimes if Paid Memberships Pro was not active. (Thanks, Karmyn Tyler Cobb)

= .5.17 =

  • Fixed bugs with multiselect fields. Now both using the field type "multiselect" or adding "multiple"=>true to the attributes for a select field will turn it into a multi select field.

= .5.16 =

  • Fixed bug with required select fields with "multiple" enabled.

= .5.15 =

  • Added the displayValue($value) method to the field class and using it in the displayInProfile method. This handles values that are arrays or indexes in a field's options.
  • Now using field labels instead of names when displaying list of fields in the required fields error message.

= .5.14 =

  • Now adding pmpro_error class to required fields if they are empty. (Thanks, Adrian)

= .5.13 =

  • Added PMPRORH_DIR constant. Now using constant to enqueue stylesheets.
  • Will now look in /themes/{YOUR THEME}/paid-memberships-pro/register-helper/css/ for copies of the CSS files, which will be used in place of the default CSS files if found.
  • Fixed required field error so it will not show duplicate warnings for fields with the same name and will use proper grammar when 1 field is missing.

= .5.12 =

  • Now looking in /themes/{YOUR THEME}/paid-memberships-pro/register-helper/ for copies of the modules .php files, which will be used in place of the default modules if found.
  • Will no longer show a checkout box on the checkout page if there are no fields in it.
  • Added fullname honey pot field to the register form module.

= .5.11.1 =

  • Added pmpro_checkout_confirm_password filter. You can disable/hide the "confirm password" field on registration by adding add_filter("pmpro_checkout_confirm_password", "__return_false"); to your active theme's functi)ons.php/etc.

= .5.11 =

  • Fixed bug where only first letter of a meta value was showing up on checkout form.

= .5.10 =

  • Fixed issue with file uploads. (Thanks, rwilki)

= .5.9 =

  • Added checkbox as a field option.

= .5.8 =

  • Now saving file info in a temp folder and $_SESSION so you can upload files using offsite gateways like PayPal Express.
  • Using single quotes so \n in HTML output echos properly. (Thanks, joshlevinson on GitHub)
  • If a "multiple" value is set on a select field, it will add the multiple property to the select element. (Thanks, joshlevinson on GitHub)
  • Added "ext" option for file fields. If set to an array of extensions, it will check that the file uploaded matches one of those extensions.
  • Added "accept" option for file fields. Sets the "accept" property of the minetype(s) given. e.g. use "image/*" to filter the file input to images.

= .5.7 =

  • Added ability to restrict checkouts by username.
  • Added hints to text fields.
  • Updated query in directory module so you can specify a comma separated list of level ids in [pmpro_directory level="1,2"]

= .5.6.1 =

  • Fixed dependency fields to work on edit user page in the admin as well.

= .5.6 =

  • Requires version 1.7.6.1 of PMPro or later.
  • Added a "memberslistcsv" option for fields. When set to true, the field will show up as a column in the Members List CSV export. (Thanks, Harsha.)
  • Fixed bug where restrict by email was case sensitive.

= .5.5.1 =

  • Fixed bug where only the first letter of a value was shown on the edit profile page.

= .5.5 =

  • Properly handling required fields of type file.
  • Checking file type and extension against WP's list for security.
  • "showrequired" defaults to true now if "required" is set.

= .5.4 =

  • Added readonly field type (displays a label and static text) and readonly property (sets the readonly property of the html element). Examples in readme.
  • Changed ids on the checkout form. The inputs will now have id = to the one set. The wrapping div will have an id like id_div.
  • Fixing up dependencies.

= .5.3 =

  • Added "radio" as a field type.
  • Added dependencies. Add something like "depends"=>array(array("otherfieldname", "otherfieldvalue")) to the arguments array and the field specified will only show up if the other field has that value.

= .5.2.1 =

  • Fixed typo in pmprorh_after_password checkout box check.

= .5.2 =

  • Supports sending false as a label to keep the label from being shown.
  • Fixed capability check in $field->displayInProfile to be "edit_user" instead of "edit_users".

= .5.1 =

  • Includes meta fields and values in checkout confirmation emails sent to admins. (But not to members. Feel free to copy the code at the bottom of pmpro-register-helper.php and tweak to send to members as well. May add a way to do this in the future with an option to turn on/off.)

= .5 =

  • Fixed bug where required fields weren't really required.
  • Added change password page module
  • Added profile page module. (Note this code needs added security, including XSS checks in the post data and wp nonce support.)
  • Added directory page module.
  • displayInProfile method for fields will show a dump of the value if the current user does not have the authority to edit the profile user.

= .4 =

  • Added the select2 and html options types.

= .3.1 =

  • Now setting $value to NULL while looping through fields in pmprorh_pmpro_after_checkout. This will keep user meta values from bleeding into other meta keys.
  • PMPro 1.5.7.1 Added the pmpro_before_send_to_paypal_standard hook. This is executed at checkout before calling the sendToPayPal method on the order. The register helper plugin has been updated to update user meta fields during this hook in addition to the pmpro_after_checkout hook. (Because for PayPal Standard, when pmpro_after_checkout is called, the $_SESSION vars are unavailable to it. So other plugins relying on the pmpro_after_checkout hook may have issues with PayPal Standard.)

= .3 =

  • Added id="pmpro_checkout_box-NAME" to pmpro_checkout tables.
  • Added pmprorh_add_checkout_box($name, $label = NULL, $description = "", $order = NULL) which will add a new section and optional description to the checkout page that you can then use in as the $where parameter in pmprorh_add_registration_field(). Updated instructions.

= .2.3 =

  • Fixed typo in pmprorh_rf_pmpro_paypalexpress_session_vars function that was keeping session vars from being saved (important for PayPal Express)
  • Updated displayAtCheckout method of the fields class to check for a value in a session var if non is set in the $_REQUEST array.
  • Fixed typo in readme example
  • Fixed the check for the "showrequired" parameter, which when set on a field adds "* required" to the field display.

= .2.2 =

  • Added the register-form.php module as a stand alone registration form. (For use without PMPro)
  • Added the "divclass" property to fields, which will add a class to the wrapping div around the fields.
  • Added a span * required to required fields.
  • Added a $pmprorh_options global. Will be putting these into a settings/options page eventually.
  • Updated pmprorh_getProfileFields to check for manage_options instead of edit_user for "admin" setting.

= .2.1 =

  • Started tracking changes.
  • Added save_function as a parameter to the add field function. This function will be called with the parameters ($user_id, $field_name, $value) when the field is saved after checkout or in the profile.

pmpro-register-helper's People

Contributors

ideadude avatar messica avatar greathmaster avatar rafpro avatar joshlevinson avatar

Watchers

James Cloos avatar Rafique avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.