Forum Replies Created
-
AuthorPosts
-
achowellMemberThanks for the help Steve, I removed scope from the code and that solved all of the issues. One last question and you can close this one, how do I set a default selection for the taxonomy dropdown?
achowellMemberOkay, I was looking for it in the wrong place! Sorry, so I missunderstoopd where this was located. It seems what I wanted was my second solution. A meta-box in the edit section of the post type. I did eventually get the taxonomy drop down on the custom post type edit page, but it does not save on update and it still has that warning message in the meta box.
Warning: array_column() expects parameter 1 to be array, object given in <plugin_path>/piklist/includes/class-piklist.php on line 2524
achowellMemberHello Steve, thanks for the reply, the parts/terms is in the plugin, this plugin also creates the mro_project post type through the piklist method. I made some edits to the field code and moved it into the meta box section and it works there. I’m not sure why its not working in the terms folder, but using it in the meta box will work for me, though its now giving me this warning.
Warning: array_column() expects parameter 1 to be array, object given in <plugin_path>/piklist/includes/class-piklist.php on line 2524
achowellMemberChanged it to the below in the terms folder and still have nothing showing up:
Title: Project Status Description: Change status of project depending on whtether the maximum number of volunteers has been reached. Taxonomy: project_status Capability: manage_options Order: 0 */ piklist('field', array( 'type' => 'select' ,'scope' => 'taxonomy' ,'field' => 'mro_project_status' ,'label' => 'Project Status' ,'description' => 'Change status of project based on amount of people registered' ,'choices' => piklist(get_terms('project_status', array( 'hide_empty' => false, )) , array( 'term_id' , 'name', ) ), ));
achowellMemberOh never mind I found out what the issue was actually, the meta_map_cap had the wrong “‘” around them that messed up the code! Sorry for the unnecessary topic.
achowellMemberYes, it still seems to do this with the code you gave me, it happens in every new post, always shows 5 extra text-area boxes.
achowellMemberThere aren’t any duplicates of that field name from what I see, I know that my WordPress version is a bit behind if that would effect anything.
achowellMemberThanks Steve, it’s in my meta-boxes folder and this is the entirety of the code for this meta box, I have one other meta box and it does not have this problem (as far as I have seen).
<?php /* Title: Project Information Post Type: mro_project Order: 2 priority: high */ ?> <?php piklist('field', array( 'type' => 'text' ,'field' => 'project_address' ,'label' => 'Address' ,'description' => 'Project Address' //,'value' => 'Default text' ,'help' => 'Enter the address of the project.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'project_city' ,'label' => 'City' ,'description' => 'City of the project' //,'value' => 'Default text' ,'help' => 'Enter the city location of the project.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'project_state' ,'label' => 'State' ,'description' => 'State of the project' //,'value' => 'Default text' ,'help' => 'Enter the state location of the project.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'project_zip' ,'label' => 'Zip' ,'description' => 'Zip Code of the project' //,'value' => 'Default text' ,'help' => 'Enter the zip code of the project.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'textarea' ,'scope' => 'post_meta' // Not used for settings sections ,'field' => 'project_description' ,'label' => 'Project Description' ,'description' => 'This is a description of the project.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'textarea' ,'scope' => 'post_meta' // Not used for settings sections ,'field' => 'project_comments' ,'label' => 'Project Comments' ,'description' => 'Enter any extra comments or notes here.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'textarea' ,'scope' => 'post_meta' // Not used for settings sections ,'field' => 'project_transport' ,'label' => 'Project Transportation' ,'description' => 'Enter transportation information on the project.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'project_limit' ,'label' => 'Volunteer Limit' ,'description' => 'Enter the max # of volunteers' //,'value' => 'Default text' ,'help' => 'If there is no limit enter 0.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'leader_limit' ,'label' => 'Team Leader Limit' ,'description' => 'Enter the max # of team leaders' ,'value' => '1' ,'help' => 'If there is no limit enter 0.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'datepicker' ,'scope' => 'post_meta' // Not used for settings sections ,'field' => 'project_date' ,'label' => 'Date' ,'description' => 'Click in box to set the date of the project' ,'attributes' => array( 'class' => 'text' ) ,'options' => array( 'dateFormat' => 'M d, yy' ,'firstDay' => '0' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'project_starttime' ,'label' => 'Start Time' ,'description' => 'Set the time the project starts' ,'help' => 'Enter the time the project starts' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'project_endtime' ,'label' => 'End Time' ,'description' => 'Set the time the project ends' ,'help' => 'Enter the time the project ends' ,'attributes' => array( 'class' => 'text' ) )); /* piklist('field', array( 'type' => 'group' ,'label' => 'Start/End Time' ,'description' => 'Set the times the project begins and ends.' ,'fields' => array( ,array( 'type' => 'text' ,'field' => 'project_start' ,'label' => '' //,'columns' => 3 ,'value' => '12:00 AM' ) ,array( 'type' => 'text' ,'field' => 'project_end' ,'label' => '' //,'columns' => 3 ,'value' => '12:00 PM' ) ) )); */ ?>
achowellMemberThanks Steve, I was able to get the meta box to display everything. But there still seems to be a problem. When I try to add a user in the form I created in this metabox to add to this specific project (an attendee table linking to the project ID the edit page is on), the POST method does not work. I know that GET works because I can use it for the ‘Remove Users’ links that are generated under the OPTIONS column of my table if there are attendees already in the database from user registration.
Here is the code and the main parts that are causing the problem are this part here –
<?php // Process add form if sent if(isset($_POST['mro_add_user'])) { $_POST = stripslashes_deep($_POST); $add_username = $_POST['mro_add_user']; if (username_exists($add_username) != NULL) { // Check not already registered $add_userid = username_exists($add_username); $extra_userdata = get_userdata($add_userid); $add_firstname = $extra_userdata->first_name; $add_lastname = $extra_userdata->last_name; $a_registered = $wpdb->get_var("SELECT user_id FROM ".$wpdb->prefix."mro_attendees WHERE event_id = ".$project_id." AND user_id = ".$add_userid); // If not already registered if ($a_registered == "") { $user_comment = $_POST['mro_add_comment']; $wpdb->insert($wpdb->prefix.'mro_attendees', array( 'event_id' => $project_id, 'user_id' => $add_userid, 'user_first_name' => $add_firstname, 'user_last_name' => $add_lastname, 'user_comment' => $user_comment ) ); ?> <div class="updated"><p><strong><?php _e('User ' . $add_username . ' added.' ); ?></strong></p></div> <?php } else { ?> <div class="updated"><p><strong><?php _e('User ' . $add_username . ' already on list.' ); ?></strong></p></div> <?php } } elseif(username_exists($add_username) == NULL) { ?> <div class="updated"><p><strong><?php _e('User ' . $add_username . ' not found.' ); ?></strong></p></div> <?php } } ?>Along with this –
<p style="clear:both;"> </p> <p style="clear:both;"><strong>Add Participant by wordpress username:</strong> </p> <form id="add_user" name="add_user" method="post" action="post.php?post=<?php echo $project_id; ?>&action=edit"> <p> <label for="mro_add_user"></label> Username<br /> <input name="mro_add_user" type="text" id="mro_add_user" size="40" maxlength="150" /> </p> <p>Comment<br /> <label for="mro_add_comment"></label> <input name="mro_add_comment" type="text" id="mro_add_comment" size="40" maxlength="40" /> </p> <p> <input type="submit" name="mro_add_user_submit" id="mro_add_user_submit" value="Add User" /> </p> </form>And this is the whole metabox for reference –
<?php /* Title: Attendee Information Post Type: mro_project Order: 3 */ ?> <?php $project_id = get_the_ID(); ?> <?php // Process add form if sent if(isset($_POST['mro_add_user'])) { $_POST = stripslashes_deep($_POST); $add_username = $_POST['mro_add_user']; if (username_exists($add_username) != NULL) { // Check not already registered $add_userid = username_exists($add_username); $extra_userdata = get_userdata($add_userid); $add_firstname = $extra_userdata->first_name; $add_lastname = $extra_userdata->last_name; $a_registered = $wpdb->get_var("SELECT user_id FROM ".$wpdb->prefix."mro_attendees WHERE event_id = ".$project_id." AND user_id = ".$add_userid); // If not already registered if ($a_registered == "") { $user_comment = $_POST['mro_add_comment']; $wpdb->insert($wpdb->prefix.'mro_attendees', array( 'event_id' => $project_id, 'user_id' => $add_userid, 'user_first_name' => $add_firstname, 'user_last_name' => $add_lastname, 'user_comment' => $user_comment ) ); ?> <div class="updated"><p><strong><?php _e('User ' . $add_username . ' added.' ); ?></strong></p></div> <?php } else { ?> <div class="updated"><p><strong><?php _e('User ' . $add_username . ' already on list.' ); ?></strong></p></div> <?php } } elseif(username_exists($add_username) == NULL) { ?> <div class="updated"><p><strong><?php _e('User ' . $add_username . ' not found.' ); ?></strong></p></div> <?php } } ?> <?php // Process remove if sent if (isset($_GET['remove_attendee'])) { $remove_attendee = (int)$_GET['remove_attendee']; } else { $remove_attendee = ''; } if ($remove_attendee != '') { $wpdb->query("DELETE FROM ".$wpdb->prefix."mro_attendees WHERE id = $remove_attendee"); $place = $_GET['place']; ?> <div class="updated"><p><strong><?php _e('Attendee '.$place.' removed.' ); ?></strong></p></div> <?php } ?> <h4>Event Participants:</h4> <p><table width="auto" border="0" align="left" cellpadding="5" cellspacing="5"> <tr> <th align="left" scope="col">Participant #</th> <th align="left" scope="col">Username</th> <th align="left" scope="col">First Name</th> <th align="left" scope="col">Last Name</th> <th align="left" scope="col">Email</th> <th align="left" scope="col">Comment</th> <th align="left" scope="col">Options</th> </tr> <?php $users = $wpdb->get_results("SELECT id, user_id, user_first_name, user_last_name, user_comment FROM ".$wpdb->prefix."mro_attendees WHERE event_id = ".$project_id." ORDER BY id ASC"); $num = 1; foreach ($users as $user) { $user_info = get_userdata($user->user_id); ?> <tr> <td><?php echo $num; ?></td> <td><?php echo $user_info->user_login; ?></td> <td><?php echo $user_info->first_name; ?></td> <td><?php echo $user_info->last_name; ?></td> <td><a href="mailto:<?php echo $user_info->user_email; ?>"><?php echo $user_info->user_email; ?></a></td> <td><?php echo $user_info->user_comment; ?></td> <td><a href="post.php?post=<?php echo $project_id; ?>&action=edit&remove_attendee=<?php echo $user->id; ?>&place=<?php echo $num; ?>">Remove User</a></td> </tr> <?php $num++; } ?> </table></p> <p style="clear:both;"> </p> <p style="clear:both;"><strong>Add Participant by wordpress username:</strong> </p> <form id="add_user" name="add_user" method="post" action="post.php?post=<?php echo $project_id; ?>&action=edit"> <p> <label for="mro_add_user"></label> Username<br /> <input name="mro_add_user" type="text" id="mro_add_user" size="40" maxlength="150" /> </p> <p>Comment<br /> <label for="mro_add_comment"></label> <input name="mro_add_comment" type="text" id="mro_add_comment" size="40" maxlength="40" /> </p> <p> <input type="submit" name="mro_add_user_submit" id="mro_add_user_submit" value="Add User" /> </p> </form> <p style="clear:both;"><strong>Participant Emails:</strong></p> <p>To keep the page simple, no mass emailer is included in this section. If you really want to email everyone you can copy the list below into your BCC to field and email them that way.</p> <blockquote> <p><?php $num = 1; foreach ($users as $user) { $user_info = get_userdata($user->user_id); echo $user_info->user_email . ", "; $num++; } ?></p> </blockquote>
achowellMemberOh never mind, I just experimented with the results and found out that this gives me the post id. I just took that and placed it in the url obtaining function from wordpress – wp_get_attachment_url() and put that in a variable to use in an echo.
I did find out if you have several media uploads on one page, that there is a bug that will cause them to be un-removable or attach in the wrong fields with the only way to fix things being to reload the page. Any idea when this bug will be fixed or if its an easy fix?
achowellMemberYeah, that was it, I was copying code from one file to another and forgot the closing bracket. Thanks for the catch!
-
AuthorPosts