• Resolved mrblues

    (@mrblues-1)


    Hello, think it will be easy code thing but could not found them yet, so, which code would remove price and location fields as there is no need to use or show them?

    cheers!

    Mr. Blues

    • This topic was modified 6 years ago by mrblues.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, you can hide the price and location fields by adding the code below in your theme functions.php file.

    
    add_filter( "adverts_form_load", "customize_adverts_add" );
    function customize_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_price" || $field["name"] == "adverts_location" ) {
            unset( $form["field"][$key] );
        }
      }
      return $form;
    }
    
    Thread Starter mrblues

    (@mrblues-1)

    I use plugin called Snippets to add these piece of codes and when I add your codes I get this error message.

    Don’t Panic
    The code snippet you are trying to save produced a fatal error on line 12:

    Cannot redeclare customize_adverts_add() (previously declared in /home/inno/public/html/sivut/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()’d code:2)
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

    what this means ?

    Plugin Author Greg Winiarski

    (@gwin)

    Seems you are already using customize_adverts_add function, you will need to change the function name, to do that instead of the previous code use the one below instead.

    
    add_filter( "adverts_form_load", "mrblues_customize_adverts_add" );
    function mrblues_customize_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_price" || $field["name"] == "adverts_location" ) {
            unset( $form["field"][$key] );
        }
      }
      return $form;
    }
    
    Thread Starter mrblues

    (@mrblues-1)

    this is working, many thanks and cheers! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need to hide ad price and location’ is closed to new replies.