• Hi,

    I have recently developped a plugin that basicaly add jobs to a page. Those jobs are added as posts and therefore I have created acustom post type. When a user add a job, it creates a post and when the user wants to edit or delete the job, the post is edited, simple enough.

    Now my issue is that this works perfectly fine in local, ir works as well in production on single wordpress site, although I cannot get it to work on multisite, post won’t get created nor edited.

    This is really mind buggling…would anybody have a clue about what’s going on ? Here is the piece of code I use to add content :

    if ($dec == 'accepted') {
    			//Selecting the row we've just modified teh status of
    			$querym = $wpdb->get_row($wpdb->prepare("SELECT * from $table where id = %s", $id));
    			//Checking the entry is not associated to an other post already (if the page gets refreshed for exemple)
    			if($querym->post_id == '0') {
    				//Adding a new post with an associated shortcode
    				//Declaring variables which will be used to make the new post
    				$job_post_shortcode = '[reso_job_post id=' . $id . ']';
    				$job_post_title = $querym->job . ', ' . $querym->location;
    				$job_post_slug = $querym->id . '-' . $querym->job . '-' . $querym->location;
    				$job_post_slug = sanitize_title($job_post_slug);
    				$new_job_post = array(
    						'post_content' => $job_post_shortcode,
    						'post_title' => $job_post_title,
    						'post_status' => 'publish',
    						'comment_status' => 'closed',
    						'ping_status' => 'open',
    						'post_name' => $job_post_slug,
    						'post_type' => 'job',
    						'comment_count' => '0'
    						);
    				wp_insert_post( $new_job_post );
    				$query = $wpdb->get_row("SELECT * from $table_posts ORDER BY id DESC LIMIT 0, 1");
    				$wpdb->update(
    							$table,
    							array(
    								'post_id' => $query->ID
    							),
    							array( 'id' => $id )
    						);
Viewing 1 replies (of 1 total)
  • see what prefix $wpdb is using maybe?

    print_r($wpdb->prefix);

    see if it’s what you expected or if it’s landing in the wrong site in multisite

Viewing 1 replies (of 1 total)

The topic ‘Cannot add or edit posts in multi site mode’ is closed to new replies.