*/ class Partnerexpo_Core_User_Fields extends Partnerexpo_Core { protected $loader; public function __construct( $loader ) { $this->loader = $loader; $this->activate_fields(); } private function activate_fields() { $this->loader->add_action( 'show_user_profile', $this, 'add_custom_user_fields' ); $this->loader->add_action( 'edit_user_profile', $this, 'add_custom_user_fields' ); $this->loader->add_action( 'user_new_form', $this, 'add_user_new_fields' ); $this->loader->add_action( 'personal_options_update', $this, 'save_custom_user_fields' ); $this->loader->add_action( 'edit_user_profile_update', $this, 'save_custom_user_fields' ); $this->loader->add_action( 'user_register', $this, 'add_value_after_reg' ); $this->loader->add_action( 'register_form', $this, 'registration_form' ); $this->loader->add_filter( 'registration_errors', $this, 'registration_errors', 10, 3 ); $this->loader->add_filter( 'comment_post', $this, 'validate_comment' ); $this->loader->add_action( 'init', function() { remove_all_filters('comment_form_defaults'); remove_all_filters('comment_form_top'); remove_all_filters('comment_form_before'); remove_all_filters('comment_form_after'); } ); } public function add_user_new_fields() { wp_enqueue_media(); ?>
|
|
|
|
|
|
add( 'company_error', sprintf('%s: %s',__( 'Error', 'partnerexpo-core' ),__( 'Cég megadása kötelező!', 'partnerexpo-core' ) ) ); } return $errors; } function validate_comment( $id ) { if ( empty( $_POST['company'] ) || ! empty( $_POST['company'] ) && trim( $_POST['company'] ) == '' ) { wp_delete_comment( $id, true ); wp_die( sprintf('%s: %s',__( 'Error', 'partnerexpo-core' ),__( 'Cég megadása kötelező!', 'partnerexpo-core' ) ) ); return false; } add_comment_meta( $id, 'company', sanitize_text_field($_POST['company']) ); if ( ! empty( $_POST['name'] ) && trim( $_POST['name'] ) != '' ) { add_comment_meta( $id, 'name', sanitize_text_field($_POST['name']) ); } return true; } }