PHP - Funcion no guarda inputs de un formulario de taxonomía personalizada en database de wordpress

 
Vista:
sin imagen de perfil

Funcion no guarda inputs de un formulario de taxonomía personalizada en database de wordpress

Publicado por Juan Alejandro (1 intervención) el 10/11/2021 21:17:40
No funciona, no me guarda los valores cuando alguien se registra en el sitio, y no encuentro el problema :( es Wordpress.




//conexión
use MyListing\Src\User_Roles;
include ('MyListing\Src\User_Roles\Profile_Fields\church-field.php');

//función para guardar en base de datos valores de taxonomy custom obtenidas de formulario de registro
function saveChurchName(){
$church_name= wp_get_current_user()->church_name;
$other_church_name= wp_get_current_user()->other_church_name;
if($church_name === "other"){
setcookie('church_name',$other_church_name);
wp_insert_term($other_church_name, 'church', array('description' => '',));
}
else{
setcookie('church_name',$church_name);
wp_insert_term($church_name, 'church', array('description' => '',));
}

}
add_action("printChurchName",saveChurchName());


// FIN

//INICIO DE ARCHIVO church-field.php

<?php

namespace MyListing\Src\User_Roles\Profile_Fields;

if ( ! defined('ABSPATH') ) {
exit;
}

class Church_Field extends Base_Profile_Field {

protected function get_posted_value() {
$value = isset( $_POST[ $this->get_form_key() ] ) ? $_POST[ $this->get_form_key() ] : '';
return sanitize_text_field( stripslashes( $value ) );
}

protected function validate() {
$value = $this->the_posted_value();
//
}

protected function field_props() {
$this->props['type'] = 'church';
}

protected function get_editor_options() {
$this->get_label_option();
$this->get_description_option();
$this->get_required_option();
$this->get_show_in_register_option();
$this->get_show_in_account_details_option();
}

public function get_form_markup() {
$churches = \MyListing\Src\Forms\Fields\Church_Field::allowed_networks(); ?>
<div class="form-group">
<p><?php echo $this->get_label() ?></p>
<div>
<div>
<script>
console.log("hello");
document.getElementById('reg_other_church_name').parentNode.style.display="none";
function change_church_name(){
if(document.getElementById('church_select').value =="other" )
document.getElementById('reg_other_church_name').parentNode.style.display="block";
else {
document.getElementById('reg_other_church_name').parentNode.style.display="none";
}
}
</script>
<select onchange="change_church_name()" id="church_select" name="church_name" class="ignore-custom-select">
<option value=""><?php _ex( 'Select The Church', 'Listing social networks', 'my-listing' ) ?></option>
<?php foreach ( $churches as $church_name ): ?>
<option value="<?php echo esc_attr( $church_name->name ) ?>">
<?php echo esc_attr( $church_name->name ) ?>
</option>
<?php endforeach ?>
<option value="other"><?php _ex( 'Other Church', 'Listing social networks', 'my-listing' ) ?></option>
</select>
</div>
</div>
</div>
<?php if ( $desc = $this->get_description() ): ?>
<p><?php echo $desc ?></p>
<?php endif ?>
<?php
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder