• Resolved af3

    (@af3)


    I am trying to add a custom column in a custom post (job manager) using the codes below, but the url is always blank ** I am newbie, appreciate any helps.

    // Add the custom columns to the job_application post type:
    add_filter( 'manage_job_application_posts_columns', 'send_message' );
    function send_message($columns) {
        $columns['message'] = 'Message';
        return $columns;
    }
    
    // Add the data to the custom columns for the job_application post type:
    add_action( 'manage_job_application_custom_column' , 'custom_send_message_column', 10, 2 );
    function custom_send_message_column( $column, $post_id ) {
        switch ( $column ) {
    
            case 'message' :
                $recent_author = get_user_by( $post_id, $recent["post_author"] );
    	    $author = $recent_author->user_login;
                $front_end_msg_url = '<a href="'.fep_query_url('newmessage', array('fep_to' => $author ) ).'">Send Message</a>';
                echo $front_end_msg_url;
            break;        
            
        }
    }
    • This topic was modified 5 years, 11 months ago by af3.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shamim Hasan

    (@shamim51)

    most of the code is ok. Just replace your case with following code

            case 'message' :
    	    $author_id = get_post_field( 'post_author', $post_id );
                $front_end_msg_url = '<a href="'.fep_query_url('newmessage', array('fep_to' => fep_get_userdata( $author_id, 'user_nicename', 'id' ) ) ).'">Send Message</a>';
                echo $front_end_msg_url;
            break; 
    
    Thread Starter af3

    (@af3)

    Thanks @shamim51
    I’ve tried that — its weird, the column still returns blank ??
    Pls help.

    Thread Starter af3

    (@af3)

    I fixed the mistake on add_action, it should be:

    add_action( 'manage_job_application_posts_custom_column' , 'custom_send_message_column', 10, 2 );
    

    Now the link was showing but all the Send Message link is to “admin”, so the _candidate_id was not returned.

    So i changed the code to this one, and it works.

    
    case 'send_message' :
      $author_id = get_post_custom_values( '_candidate_user_id', $post_id );
      $user_info = get_userdata($author_id[0]);
      $user_name = $user_info->user_login;
      $front_end_msg_url = '<a href="'.fep_query_url('newmessage', array('fep_to' => $user_name ) ).'">Send Message</a>';
      echo $front_end_msg_url;
      break; 

    Thanks!!!

    • This reply was modified 5 years, 11 months ago by af3.
    • This reply was modified 5 years, 11 months ago by af3.
    • This reply was modified 5 years, 11 months ago by af3.
    • This reply was modified 5 years, 11 months ago by af3.
    • This reply was modified 5 years, 11 months ago by af3.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add prepopulated msg link in custom column (backend)’ is closed to new replies.