Hi!
I’m suspecting the “auto” option is carried in the wp-admin (so in SportsPress when you set to nothing and is creating a post via wp-admin it’ll be added to the player list).
What you could do to debug is test:
1) What are the custom fields for a new player via wp-admin X your plugin
2) What happens when you update a player, what POST data is being sent
Kind Regards,
-Roch
Just to clarify, this is what i do when i add a player via my own plugin
public function myplugin_add_player($post_data, $player, $team_slug) {
$post_id = wp_insert_post($post_data);
$player_name_slug = strtolower($player->first_name . '-' . $player->last_name);
$player_team_slug_short = substr($team_slug, 4);
# Set Position
wp_set_object_terms($post_id, $player->position_name, 'sp_position', false);
# Set League
wp_set_object_terms($post_id, 'NFL', 'sp_league', false);
# Set Nationality
update_post_meta($post_id, 'sp_nationality', trim(strtolower($player->country)));
# Set Team And Current Team
update_post_meta($post_id, 'sp_current_team', $this->nfl_team_slug[$team_slug]);
# Set Player Image
$this->gulklud_get_player_image($player_team_slug_short, $player_name_slug, $player->name, $post_id);
}
This is the post data being sent when i create one on via wp-admin
_wpnonce:f9a2db03c2
_wp_http_referer:/wp-admin/post-new.php?post_type=sp_player
user_ID:3
action:editpost
originalaction:editpost
post_author:3
post_type:sp_player
original_post_status:auto-draft
referredby:http://nflgeeks.com/wp-admin/admin.php?page=gulklud
_wp_original_http_referer:http://nflgeeks.com/wp-admin/admin.php?page=gulklud
auto_draft:
post_ID:10235
meta-box-order-nonce:67011d791a
closedpostboxesnonce:d8dca0bca2
post_title:Andreas Quist
samplepermalinknonce:06103d97ee
content:
wp-preview:
hidden_post_status:draft
post_status:draft
hidden_post_password:
hidden_post_visibility:public
visibility:public
post_password:
mm:08
jj:02
aa:2016
hh:07
mn:31
ss:05
hidden_mm:08
cur_mm:08
hidden_jj:02
cur_jj:02
hidden_aa:2016
cur_aa:2016
hidden_hh:07
cur_hh:07
hidden_mn:31
cur_mn:31
original_publish:Udgiv
publish:Udgiv
menu_order:0
_um_custom_access_settings:0
_um_accessible:0
_um_access_redirect2:
_um_access_roles[]:0
_um_access_redirect:
um_admin_save_metabox_access_nonce:a276ef939f
_wp_http_referer:/wp-admin/post-new.php?post_type=sp_player
sp_twitter:
sp_columns[]:0
sp_columns[]:0
sportspress_meta_nonce:39166d70b2
_wp_http_referer:/wp-admin/post-new.php?post_type=sp_player
sp_number:
sp_nationality[]:den
tax_input[sp_position][]:0
sp_current_team[]:2645
tax_input[sp_league][]:0
tax_input[sp_league][]:16
tax_input[sp_season][]:0
sp_metrics[height]:
sp_metrics[weight]:
excerpt:
post_name:
post_author_override:3
slide_template:default
twitter_custom:4a1ec65607
_wp_http_referer:/wp-admin/post-new.php?post_type=sp_player
twitter_share[text]:
twitter_share[hashtags]:
twitter_card[title]:
twitter_card[description]:
Roch, you got any idea what is going on?
Hi!
Here the ones that I don’t see in your code are
sp_current_team[]:2645
And
tax_input[sp_league][]:16
You are setting them via the slug in your code, so maybe that is why it isn’t working.
Have you tried using the ID instead?
Kind Regards,
-Roch
I am actually using the ID, nfl_team_slug returns the ID of the team.
Is there anyway I can use your CSV importer in my own plugin, to import the players? The problem is that I’m getting all the players from a JSON endpoint in my own plugin and create the players trough that.
Roch, how can i import all my players from JSON endpoint into your custom post type? I’ve tried anything possible now or is it even possible to post to the import function you have in your plugin?
Hi, I’m having exactly the same problem as @clownay.
I can see inside the player edit that the club is set, but it doesn’t appear in the list of players, and neither in the players list of the team. Im’m setting the team with Id and everything, but it seems I’m lacking something else, or there is a meta that I’m not setting regarding clubs.
Ok, I found the problem.
You have to set sp_team like sp_currentteam. Otherwise the system doesn’t know it. Then it will appear everywhere correctly.
I hope this helps you @clownay!