• Resolved argate7

    (@argate7)


    Hi,

    I’ve created 2 columns in wp_posts, post_language and post_project, because i want to view certain posts and media according the session that i passed from another site to the wordpress.

    Now, i’ve got a problem in media section. I’m trying to insert a media and give the 2 columns values but i cannot achieve this.
    In my plugin i have this one..

    function modify_columns( $post_id ) {
    	remove_action( 'save_post', 'modify_columns' );
    	wp_update_post( array( 'ID' => $post_id, 'post_project' => "".$_SESSION['project']."", 'post_language' => "".$_SESSION['language']."" ) );
    	add_action( 'save_post', 'modify_columns' );
    }

    add_action(‘save_post’, ‘modify_columns’);

    function wp_insert_post_data_filter( $data, $postarr ) {
    $data[‘post_project’] = $_SESSION[‘project’];
    $data[‘post_language’] = $_SESSION[‘language’];
    return $data;
    }

    add_filter( ‘wp_insert_post_data’, ‘wp_insert_post_data_filter’, 10, 2 );

    This is in order to pass the values to the 2 columns. This works like a charm in posts and pages section. But in media there is a problem.
    
    Is there anyone that can help me resolve this one?
    
    I forgot to mention that if i placed this code

    $data[‘post_project’] = $_SESSION[‘project’];
    $data[‘post_language’] = $_SESSION[‘language’];`
    in post.php in wp_insert_post function before if ( ‘attachment’ === $post_type ) { it works, but i don’t want to change the core files because if i update the wp, i will lose all my changes.

    Please help me resolve this!

    Thank you in advance!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘custom fields’ is closed to new replies.