• Resolved GLADIT

    (@gladit)


    Hey Greg,

    i have two problems first of all the edit and publish button after the preview doesn’t work for me (no function)

    I make a menue test button for you (http://www.virtual-reality-agentur.de/test-publish/)

    User: Hamburg
    PW: hamburg

    Second problem is i tried to make the price requiered. Same as location and category which worked perfectly. But the price isn’t requiered. Whats wrong with my code? All is in my child theme / function.php

    //for category requiered
    add_filter( 'adverts_form_load', 'my_adverts_form_require_category' );
    function my_adverts_form_require_category( $form ) {
        if($form['name'] != 'advert') {
            return $form;
        }
    
        if(!is_admin()) {
            foreach($form['field'] as $k => $field) {
                if($field['name'] == 'advert_category') {
                    $field['is_required'] = true;
                    if( ! isset($field['validator']) || !is_array($field['validator'])) {
                        $field['validator'] = array();
                    }
                    $field['validator'][] = array( 'name' => 'is_required' );
    
                    $form['field'][$k] = $field;
                    break;
                }
            }
        }
    
        return $form;
    }
    
    //for location requiered
    add_filter( 'adverts_form_load', 'my_adverts_form_require_location' );
    function my_adverts_form_require_location( $form ) {
        if($form['name'] != 'advert') {
            return $form;
        }
    
        if(!is_admin()) {
            foreach($form['field'] as $k => $field) {
                if($field['name'] == 'adverts_location') {
                    $field['is_required'] = true;
                    if( ! isset($field['validator']) || !is_array($field['validator'])) {
                        $field['validator'] = array();
                    }
                    $field['validator'][] = array( 'name' => 'is_required' );
    
                    $form['field'][$k] = $field;
                    break;
                }
            }
        }
    
        return $form;
    }
    
    //for price requiered
    add_filter( 'adverts_form_load', 'my_adverts_form_require_price' );
    function my_adverts_form_require_price( $form ) {
        if($form['name'] != 'advert') {
            return $form;
        }
    
        if(!is_admin()) {
            foreach($form['field'] as $k => $field) {
                if($field['name'] == 'adverts_price') {
                    $field['is_required'] = true;
                    if( ! isset($field['validator']) || !is_array($field['validator'])) {
                        $field['validator'] = array();
                    }
                    $field['validator'][] = array( 'name' => 'is_required' );
    
                    $form['field'][$k] = $field;
                    break;
                }
            }
        }
    
        return $form;
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]

    Thank you!!

    https://ww.wp.xz.cn/plugins/wpadverts/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    1. seems your theme CSS is conflicting with WPAdverts CSS try adding in your theme CSS file following code

    form { display: block !important }

    2. right now the Price field cannot be made required because it is executing a filter before validation which never makes the price empty, other than that your validation seems fine to me.

    Thread Starter GLADIT

    (@gladit)

    Hey Greg,

    thank you for your answer. That worked fine for me and was definitely the biggest prob 🙂

    Wish you a nice weekend!

    BB

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, sure no problem.

    BTW. If you are finding the plugin useful i would be thankful if you could write a short one or two sentence review here https://ww.wp.xz.cn/support/view/plugin-reviews/wpadverts

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Edit / Publish Button no function’ is closed to new replies.