Home Forums Plugin Support WP User Frontend Pro Action hook on edit

This topic is: not resolved

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitri 5 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18763

    Dimitri
    Member
    Post count: 20

    Hi,

    I’ve used this code in order to:

    1) generate a password
    2) saving into a custom field
    3) add password to the URL

    function add_custom_field_automatically( $post_id ) {
        
    	$passord_progetto = wp_generate_password(6, false, false); 
    	
    	if ( isset( $passord_progetto) ) {
            update_post_meta( $post_id, 'password_ordine', $passord_progetto );
        }
    }
      
    add_action( 'wpuf_add_post_after_insert', 'add_custom_field_automatically' );
    add_action( 'wpuf_edit_post_after_update', 'update_my_brand_new_hook' );
    
    // ADD QUERY VAR PASSWORD ORDINE
    add_filter( 'post_type_link', 'wpchef_ordine_url', 10, 2 );
    function wpchef_ordine_url( $url, $post ) {
    	
    	if ( 'project' !== $post->post_type )
            return $url;
    	
    	$password = get_post_meta( $post->ID, 'password_ordine', true );
    	
        return add_query_arg( 'psw', $password, $url );
    	
    }

    When I create a new post (project) all works well.

    The problem is when I EDIT the post the password is deleted.

    Could you give me some hints?

    Thank you.

    D.

    #18777

    Tareq Hasan
    Keymaster
    Post count: 2831

    Just remove this line? add_action( 'wpuf_edit_post_after_update', 'update_my_brand_new_hook' );.

    #18802

    Dimitri
    Member
    Post count: 20

    Strangely it doesn't work even if I remove that line.. and I don't understand why..

    #18806

    Dimitri
    Member
    Post count: 20

    This is the custom Edit url that I use

    <?php 
    						
    						if ( current_user_can( 'delete_others_posts' ) || $post->post_author == get_current_user_id() ) {
    							  $edit_page = (int) wpuf_get_option( 'edit_page_id', 'wpuf_general' );
    							  $url = add_query_arg( array('pid' => $post->ID), get_permalink( $edit_page ) );
    						  
    							  printf( '<a href="%s" class="bottone_new_project">%s</a>', wp_nonce_url( $url, 'wpuf_edit' ), __( 'Edit this project', 'wpuf' ) );
    }
    						
    						?>
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Action hook on edit’ is closed to new replies.