function pcud_form_shortcode($atts, $content = null) { require_once PC_DIR . '/classes/pc_form_framework.php'; $f_fw = new pc_form(); include_once PCUD_DIR . '/functions.php'; extract(shortcode_atts(array('form' => '', 'layout' => ''), $atts)); if (!filter_var($form, FILTER_VALIDATE_INT)) { return false; } // execute only if pvtContent or WP user is logged $pc_logged = pc_user_logged(false); if (!$pc_logged && !current_user_can(get_option('pg_min_role', 'upload_files'))) { return false; } // ignore testing mode $user_id = $pc_logged ? $GLOBALS['pc_user_id'] : 0; // form structure $term = get_term_by('id', $form, 'pcud_forms'); if (empty($term)) { return false; } if (empty($term->description)) { // retrocompatibility $form_fields = (array) get_option('pcud_form_' . $form, array()); } else { $form_fields = unserialize(base64_decode($term->description)); } // layout if (empty($layout) || !in_array($layout, array('one_col', 'fluid'))) { $layout_class = 'pc_' . get_option('pg_reg_layout', 'one_col') . '_form'; } else { $layout_class = 'pc_' . $layout . '_form'; } $form = ' <form class="pc_custom_form pc_custom_form_' . $form . ' ' . $layout_class . '"> <input type="hidden" name="pcud_fid" value="' . $form . '" />'; $form .= $f_fw->form_code(pcud_v2_field_names_sanitize($form_fields), false, $user_id); $form .= ' <div class="pc_custom_form_message"></div> <input type="button" class="pc_custom_form_btn" value="' . __('Submit', 'pcud_ml') . '" /> </form>'; return str_replace(array("\r", "\n", "\t", "\v"), '', $form); }
function pc_registration_form($form_id = '', $layout = '', $forced_cats = false, $redirect = false) { include_once PC_DIR . '/classes/pc_form_framework.php'; include_once PC_DIR . '/classes/recaptchalib.php'; // if is not set the target user category, return an error if (!get_option('pg_registration_cat')) { return __('You have to set registered users default category in settings', 'pc_ml'); } else { $f_fw = new pc_form(array('use_custom_cat_name' => true, 'strip_no_reg_cats' => true)); //// get form structure // if form not found - get first in list if (!(int) $form_id) { $rf = get_terms('pc_reg_form', 'hide_empty=0&order=DESC&number=1'); if (empty($rf)) { return __('No registration forms found', 'pc_ml'); } $rf = $rf[0]; } else { $rf = get_term($form_id, 'pc_reg_form'); if (empty($rf)) { $rf = get_terms('pc_reg_form', 'hide_empty=0&order=DESC&number=1'); if (empty($rf)) { return __('No registration forms found', 'pc_ml'); } $rf = $rf[0]; } } $form_structure = unserialize(base64_decode($rf->description)); if (!is_array($form_structure) || !in_array('username', $form_structure['include']) || !in_array('psw', $form_structure['include'])) { return __('Username and password fields are mandatory', 'pc_ml'); } // disclaimer inclusion if (get_option('pg_use_disclaimer')) { $form_structure['include'][] = 'pc_disclaimer'; } // PC-FILTER - manage registration form structure - passes structure array and form id $form_structure = apply_filters('pc_registration_form', $form_structure, $rf->term_id); // layout class $layout = empty($layout) ? get_option('pg_reg_layout', 'one_col') : $layout; $layout_class = 'pc_' . $layout . '_form'; // custom category parameter if (!empty($forced_cats) && !in_array("categories", $form_structure['include'])) { $cat_attr = 'pc_cc="' . $forced_cats . '"'; } else { $cat_attr = ''; } // custom redirect attribute if (!empty($redirect)) { $redir_attr = 'pc_redirect="' . $redirect . '"'; } else { $redir_attr = ''; } //// init structure $form = '<form class="pc_registration_form pc_rf_' . $rf->term_id . ' ' . $layout_class . '" ' . $cat_attr . ' ' . $redir_attr . ' rel="' . $rf->term_id . '">'; $custom_fields = ''; //// anti-spam system $antispam = get_option('pg_antispam_sys', 'honeypot'); if ($antispam == 'honeypot') { $custom_fields .= $f_fw->honeypot_generator(); } else { $publickey = "6LfQas0SAAAAAIdKJ6Y7MT17o37GJArsvcZv-p5K"; $custom_fields .= ' <script type="text/javascript"> var RecaptchaOptions = {theme : "clean"}; </script> <li class="pc_rf_recaptcha">' . pc_recaptcha_get_html($publickey) . '</li>'; } $form .= $f_fw->form_code($form_structure, $custom_fields); $form .= ' <div id="pc_reg_message"></div> <input type="button" class="pc_reg_btn" value="' . __('Submit', 'pc_ml') . '" /> </form>'; return $form; } }