Home Forums Plugin Support WP User Frontend Pro Action hook for register form

This topic is: resolved

This topic contains 2 replies, has 1 voice, and was last updated by  ced 4 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27895

    ced
    Participant
    Post count: 32

    Hi,
    It could be great to have an example for the action hook in register form.
    What are the datas diiferents from the post form hook ?

    function render_my_awesome_hook( $form_id, $post_id, $form_settings ) {
        $value = '';
      
        if ( $post_id ) {
            $value = get_post_meta( $post_id, 'your_meta_key', true );
        }
        ?>
      
        <div class="wpuf-label">
            <label>A demo field</label>
        </div>
      
        <div class="wpuf-fields">
            <input type="text" name="my_custom_field" value="<?php echo esc_attr( $value ); ?>">
        </div>
        <?php
    }
     
    add_action( 'my_awesome_hook', 'render_my_awesome_hook', 10, 3 );
    function update_my_brand_new_hook( $post_id ) {
        if ( isset( $_POST['my_custom_field'] ) ) {
            update_post_meta( $post_id, 'your_meta_key', $_POST['my_custom_field'] );
        }
    }
      
    add_action( 'wpuf_add_post_after_insert', 'update_my_brand_new_hook' );
    add_action( 'wpuf_edit_post_after_update', 'update_my_brand_new_hook' );
    #27942

    ced
    Participant
    Post count: 32

    May, we, have, please, a, working, example.
    And an answer on this forum ?

    #27945

    ced
    Participant
    Post count: 32

    Never mind !

    function render_your registrationfield( $user_id, $userdata, $form_id, $form_settings ) {
    		$value = '';
    		if ( $user_id ) {
    			$value = get_user_meta( $user_id, 'YOURFIELD_META', true );
    		}
    		?>
    			<div class="wpuf-label">
    				<label>your label<span class="required">*</span></label>
    			</div>
    			<div class="wpuf-fields">
    				your field
    			</div>
    
    		<?php
    	}
    	add_action( 'your registrationfield', 'render_your registrationfield', 10, 3 );
    	
    	/**
    	 * Update the custom field when the form submits
    	 *
    	 * @param type $post_id
    	 */
    	function update_your registrationfield( $user_id ) {
    		if ( isset( $_POST['YOURFIELD'] ) ) {
    			update_user_meta( $user_id, 'YOURFIELD_META', $_POST['YOURFIELD'] );
    		}
    	}
    	add_action( 'wpuf_after_register', 'update_your registrationfield' );
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Action hook for register form’ is closed to new replies.