- This topic has 4 replies, 2 voices, and was last updated 1 year ago by .
To explain – I have set up a membership post-type to hold membership details for WordPress Users. Naturally the membership post has a ‘user_id’ post meta. And users have a ‘membership_id’ user-meta. In the Membership meta-box there is a user field with select-type ‘select advanced’. Now I tried to make things easier for the admin when adding a new membership by restricting the list of user ids shown to only those who have no membership already. Ok that works fine, simplifies adding a new members. The problem is when editing a membership then the user-name is not shown at all – of course the user now has a membership so is excluded by the query, and cannot be selected. When the post is saved, the user-id is removed from the membership post meta! This happens even if you do not try to update the user.
My current code below. So my question now is – is there any way to include current value of the user-id field on meta-box edit – I would not expect the user id to change once a membership is set up so maybe it can be set to read-only for Edit?
Thanks for any guidance on this
'fields' => array( array( 'name' => 'Member', 'desc' => 'The user holding this membership - must already exist', 'id' => SHS_POST_META_PREFIX . 'user_id', 'type' => 'user', 'field_type' => 'select_advanced', 'placeholder' => 'Select member', 'query_args' => array( 'meta_query' => array( 'relation' => 'or', array( 'key' => SHS_POST_META_PREFIX . 'membership_id', 'value' => 0, 'compare' => 'NOT EXISTS', 'type' => 'numeric', ), array( 'key' => SHS_POST_META_PREFIX . 'membership_id', 'value' => 0, 'compare' => '=', 'type' => 'numeric', ) ) ), ),
- You must be logged in to reply to this topic.