• Greetings.

    Some time ago i asked about some settings to add custom fields without the Custom Fields Add On. Thinking in that option i thought that could be possible to add such fields on the Registration form. After looking the WPAdverts core and WP Adverts Custom fields i kind of reach the objective.

    This is an User Registration from the Authors add on with an addition on the functions.php of the theme. (If the live site is not available)
    https://imgur.com/a/8Tlf3GG

    I reached it adding this code on the functions.php of the theme:

    add_filter( "adverts_form_load", "featured_xx"  );
    function featured_xx( $form_scheme ) {
        
        
    	$form_scheme['field'][] = array(
                "name"      => "_item_author_demo",
                "type"      => "adverts_field_header",
                "order"     => 10005,
                "label"     => __( 'DEMO', 'wpadverts-authors' )
            );
    	$form_scheme['field'][] = array(
                "name"      => "_item_author_image1",
                "type"      => "adverts_field_gallery",
                "order"     => 10006,
                "label"     => __( 'Cargar', 'wpadverts-authors' ),
    			"validator" => array(
                    array(
                        "name" => "upload_type",
                        "params" => array( "allowed" => array( "image" ) )
                    )
                )
            );
    	return $form_scheme;
    }

    But I have 2 Unexpected Side Effects:

    • First is that the Image / Gallery component doesnt work at all, i’m not fully sure how to enable it to add what i need (Since it is plausible that i require a second field of that kind
    • Second After adding the first field on the search bar it added automatically an “Advanced Search” dropdown, but i can’t remove it without hiding it via CSS (which can be done but i don’t think that is the correct solution), since i think that the addition throws an error once is deployed.

    I know that it seems a bit tricky but if the experience i had first on the manual custom fields serves me of something the additional fields allow me to add that data to the profile and display it as i need it.

    Thanks in advance for the help you can provide.

    The page I need help with: [log in to see the link]

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

    (@gwin)

    Hi,
    1. the Author Registration form does not support the Gallery field yet, so while you can have it displayed there it will not work.

    2. the adverts_form_load filter is run on all forms, so the way you have the code right now these two fields will show in every single WPAdverts form.

    To have it shown in the Author registration only at the beginning of the function you should have the below code

    
    if( $form_scheme["name"] != "author_profile" ) {
      return $form_scheme;
    }
    
    Thread Starter johndoe01

    (@johndoe01)

    Thanks a lot! IT WORKS.

    The additional fields are now set only on the registration form so there is no advanced search dropdown.

    And speaking of unexpected results…
    ..the gallery component I can pass to the next stage which is ask for the photo. Although throws Checksum error (by the lack of support for that area) i could see if i can reach something close.

    At least by not deploying the advanced search dropdown i’m satisfied. I’ll try something to try to enable the upload and i’ll let you know here.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding Field on Registration form + Unexpected Results’ is closed to new replies.