This entry is part 2 of 8 in the Customizing Restrict Content Pro Series
- Mail Chimp for Restrict Content Pro
- Add Custom User Meta Fields to Restrict Content Pro Registration
- Removing “Restrict This Content” Meta Box in Restrict Content Pro
- Restrict Content Pro – Campaign Monitor
- Restrict Content Pro – Graphs
- Restrict Content Pro – Stripe Payment Gateway
- Hide wp-login.php with Restrict Content Pro
- Add a Agree to Our Terms of Use Field to Restrict Content Pro
Restrict Content Pro is my premium content plugin that makes it very easy to sell subscriptions to your WordPress website. It is the plugin that powers the subscription system to this site. This subscribers’s only tutorial is going to walk you through the process of adding new form fields to the registration form, and then storing the data enter in those fields in the user’s meta. I will also cover how to output the newly acquired information in the Members page of the plugin admin section.
The gist of what we are going to be doing in this tutorial can be see in the two screenshots below:
The complete code written in the video is below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
function pippin_add_location_field() {
?>
<p>
<label for="rcp_location"><?php _e('Your Location', 'rcp'); ?></label>
<input name="rcp_location" id="rcp_location" type="text"/>
</p>
<?php
}
add_action('rcp_after_password_registration_field', 'pippin_add_location_field');
function pippin_save_location($posted, $user_id) {
if($posted['rcp_location']) {
update_user_meta($user_id, 'rcp_location', $posted['rcp_location']);
}
}
add_action('rcp_form_processing', 'pippin_save_location', 10, 2);
function pippin_add_table_header_footer() {
?>
<th class="rcp-location-col"><?php _e('Location', 'rcp'); ?></th>
<?php
}
add_action('rcp_members_page_table_header', 'pippin_add_table_header_footer');
add_action('rcp_members_page_table_footer', 'pippin_add_table_header_footer');
function pippin_add_row($user_id) {
?>
<td><?php echo get_user_meta($user_id, 'rcp_location', true); ?></td>
<?php
}
add_action('rcp_members_page_table_column', 'pippin_add_row'); |
Related Items



Hi,
Is it possible to create multiple registration froms for different custom role for my project in WP with user meta, and at the same time i need customize the form with my own CSS.
when user login we need give update they profile with profile picture.
please help me
thanks
BA Kumar
Yes, it is possible, but only if you know how to do it by copying the existing form and creating a second one.
There are several plugins out there that allow users to set profile images, but there is not a way included with RCP.
Hi,
Thank you for reply, but i s short. if you have free time please provide detailed explanation.
it very important who search multiple registration forms like me.
please help me
Thank you
Duplicating the forms is not too difficult, but it goes far beyond the scope of the support you get included with the plugin purchase.
where I can add this code?
Your theme’s functions.php or any custom plugin is fine.
i added the code but it’s not working. Location is not showing on back end. How can I fix it. How can I add more field?
now problem has been solved. do you have any option to add moneybookers ? how can i add?
In order to use Money Bookers, you will have to build a custom payment gateway. How comfortable with PHP are you?
Hi, How do I add multiple fields. I was able to add location, but when i copy and alter for a 2nd field I get an error which seems like I can’t add 2 identical hooks:
Fatal error: Cannot redeclare pippin_add_table_header_footer() (previously declared in /home/condo/public_html/condo/wp-content/plugins/custom-functions/custom-functions.php:50) in /home/condo/public_html/condo/wp-content/plugins/custom-functions/custom-functions.php on line 86
Kyle, you have to change the name of the second function/hook. As you noted, they cannot be the same. Just renamed the second pippin_add_table_header_footer() to something else and then also rename it in the add_action().
This modification is great, i’m using to add multiple fields however, another 14 records, which works fine, until I get to the admin section.
All the columns are added, however they get *squashed*, editing the admin-style.css file and adding extra CSS records.. as follows :
.rcp-user-col { width: 100px; }
.rcp-id-col { width: 50px; }
.rcp-email-col { width: 180px; }
.rcp-sub-col { width: 140px; }
.rcp-status-col { width: 70px; }
.rcp-recurring-col { width: 90px; }
.rcp-expiration-col { width: 140px; }
.rcp-role-col { width: 90px; }
.rcp-city-col { width: 70px; }
.rcp-state-col { width: 70px; }
.rcp-country-col { width: 90px; }
.rcp-postcode-col { width: 70px; }
.rcp-phone-col { width: 40px; }
.rcp-mobile-col { width: 40px; }
.rcp-dob-col { width: 40px; }
.rcp-age-col { width: 25px; }
.rcp-sex-col { width: 40px; }
.rcp-parents-col { width: 90px; }
.rcp-hsyear-col { width: 40px; }
.rcp-hs-col { width: 70px; }
.rcp-hsaddress-col { width: 90px; }
.rcp-handicap-col { width: 50px; }
.rcp-actions-col { }
once I get to a certain number the action column completely vanishes and i’m unsure why
any idea / assistance on why this would be occuring? or is there a different way to view/edit the data?
How many columns do you have with your modified code?
If the answer to that is “Lots and lots” – is there a hook to add fields to the detail view, instead of the list view in the admin area?
And the answer of course is yes. Checking the source I found rcp_view_member_after:
function pippin_add_fields($user_id) { ?>
<?php
}
add_action('rcp_view_member_after', 'pippin_add_fields');
Hope that helps someone. This plugins code really is very well written.
Your code was stripped out, please post again via snippi.com
http://snippi.com/s/kepbxqh
Really the key thing is what the hook is, but yeah. Here is an example of what I’m adding (its actually like 20 fields)
Thanks for reposting!
Using your example of “location”. How would I have the content of that input added to the email that is sent to the admin on submit? Currently it just shows
Whoops that go cut off. Currently one email shows first and last name, the other shows username and email.
Are you familiar with using filters in WordPress?
hi, I am adding like 4 new filed in RCP plugin the way you described above. I have couple of question. First one i want to make my new field required field how can i make my new fields required field. I explored your Member-form.php you are using there like to make field required . i am trying for my flied like function pippin_add_dlic_field(){
?>
but its not wrking.
2nd question when i see my new field in restrict Member area in word press its look weird not with sequence and how can i fetch all field from database by using user id. like i want to see all field info of user. how can i fetch all field from database. thanks Plz reply me asap.
1. To make a field required, you need to check if the data is present when the form is submitted and then set an error if it isn’t. See this tutorial.
2. Can you give me a screenshot? You can’t fetch all the fields at once; each one has to be fetched individually.
here is screen
http://s1278.beta.photobucket.com/user/mian325/media/screen_zps463343cb.jpg.html?sort=3&o=0
1- Plz have look for my new field code for required field
http://snippi.com/s/xt63dtb
2- Here is snap shot of my Members in restrict content pro
http://s1278.beta.photobucket.com/user/mian325/media/screen_zps463343cb.jpg.html
is there any way that i can display my total number of active members by using restrict content pro plugin. I want to display on my page how much member i have now and it will update as member increase. Plz help me how can i do that
I’ve responded to your ticket in the support forum.
I successfully added two new fields to the form – thank you!
My issue: Can you explain how to move the two new fields to display after the Email field and before the Username field? I would like…
First Name
Last Name
Email
Your Company
Phone Number
Username
Password
Password again
Sorry but that is not possible.
Hi, When my expired user try to pay subscription again register button does not work. Same if one user get member and decided to pay subscription later. Later he get login and try to pay by paypal by clicking on register button he cant pay.. register button dont go to paypal page. Please let me know what is wrong.
Please open this as a support ticket: http://support.pippinsplugins.com/forums/forum/restrict-content-pro/
This tutorial is not the place to ask for support.
Can the user then update this meta information or is it only on registration?
It is possible to make that happen but the code is this tutorial does not make that possible.
I solved this by using the “User Meta Manager” plugin by simply adding the new meta fields. Worked straight away without any fuss so users can now go their profile page and update the fields.
Great!
How do I remove the auto renew tickbox and as default have it not to auto renew (I am only offering free subscriptions)?
Post this in the support forums and I’ll be happy to help.