Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Pre-populate form 25 with user meta data from currently logged in user */
- add_filter("gform_pre_render_25", "sunrise_prepopulate_form_from_user_meta");
- function sunrise_prepopulate_form_from_user_meta($form) {
- global $current_user;
- get_currentuserinfo();
- global $post;
- foreach($form["fields"] as &$field) {
- if($field["inputName"] != "") {
- $thisInput = explode("__", $field["inputName"]);
- if($thisInput[0] == 'usermeta') {
- $_GET[$field["inputName"]] = $current_user->__get($thisInput[1]);
- } elseif($thisInput[0] == 'personmeta' && $post->post_type == 'people') {
- $_GET[$field["inputName"]] = get_post_meta($post->ID, $thisInput[1], true);
- } elseif($thisInput[0] == 'organizationmeta' && $post->post_type == 'organizations') {
- $_GET[$field["inputName"]] = get_post_meta($post->ID, $thisInput[1], true);
- }
- }
- }
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement