Jump to content

jaek

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jaek's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Nice one! that is now working. Is there any reason this hack is not recommended? as I dont want to waste your time if this is a viable solution The functions I have found are below.. <?php function more_fields($key, $before = '', $after = '', $content_filter = false) { $value = get_meta($key); if (!$value) return false; echo $before; if ($content_filter) echo apply_filters('the_content', $value); else echo $value; echo $after; return true; } /* ** get_box ( ) ** */ function get_box ($name, $args = array()) { global $more_fields; global $post; $html = ''; $nl = "\n"; // Get our fields $more_fields = $more_fields->get_objects(array('_plugin_saved', '_plugin')); // Parse args $defaults = array('format' => 'ul', 'div' => '', 'show' => '', 'title' => ''); $args = wp_parse_args($args, $defaults); if (!is_array($more_fields)) return '<!-- No More Fields are defined -->'; if (!array_key_exists($name, $more_fields)) return "<!-- The box name '$name' does not exist! -->"; // Make sure we've got someting to display $something = false; foreach ((array) $more_fields[$name]['field'] as $field) if (get_post_meta($post->ID, $field['key'], true)) $something = true; if (!$something) return "<!-- Nothing to display for '$name' -->"; // Iterate through our meta fields and generat some html for ($i=0; $i < count($more_fields[$name]['field']); $i++) { $key = $more_fields[$name]['field'][$i]['key']; $title = $more_fields[$name]['field'][$i]['title']; // Set up the list if ($i == 0) { if ($args['div']) $html .= '<div id="' . $args['div'] .'">' . $nl; if ($args['format']) { $caption = ($args['title']) ? ($args['title']) : $name; $html .= '<h3 class="meta_widget_header">' . $caption . '</h3>' . $nl; $html .= '<' . $args['format'] . '>' . $nl; } } // Does this field qualify for being shown? $show = false; if (is_array($args['show'])) { for ($k = 0; $k < count($args['show']); $k++) if ($args['show'][$k] == $key) $show = true; } else if (!$args['show'] || ($args['show'] == $key)) $show = true; $value = get_post_meta($post->ID, $key, true); if ($show && $value) { // Amost the same as 'the_content' filter $value = preg_replace("/\n/", "<br />", $value); $value = wptexturize($value); $value = convert_chars($value); $style_li = ' class="meta_' . $key . '_ul"'; $style_dt = ' class="meta_' . $key . '_dt"'; $style_dd = ' class="meta_' . $key . '_dd"'; if ($args['format'] == 'ul') $html .= "<li ${style_li}>" . $value . '</li>' . $nl; else if ($args['format'] == 'dl') $html .= "<dt ${style_dt}>" . $title . "</dt><dd ${style_dd}>" . $value . '</dd>' . $nl; else if ($args['format'] == 'p') $html .= $value . $nl; else $html .= $value . $nl; } // Close the list and the optional div if ($i == count($more_fields[$name]['field']) - 1) { if ($args['format']) $html .= '</' . $args['format'] . '>' . $nl; if ($args['div']) $html .= '</div>' . $nl; } } echo $html; } /* ** get_meta ( ) ** */ function get_meta ($meta, $id = '') { global $post; if ($id) $meta = get_post_meta($id, $meta, true); else { $id = (get_the_id()) ? get_the_id() : $post->ID; $meta = get_post_meta($id, $meta, true); } return $meta; } function meta ($meta, $id = '') { echo get_meta($meta, $id); } /* ** more_fields_img() ** */ function more_fields_img($meta, $before = '', $after = '', $options = array()) { $defaults = array('height' => 0, 'width' => 0, 'size' => '', 'crop' => false); $options = wp_parse_args( $options, $defaults ); if ( ! ( $id = get_meta($meta) ) ) return false; // If the image size does not exist, make it if ( !$options['size'] && ($options['height'] || $options['width'] ) ) { $size = 'mf_h' . $options['height'] . '_w' . $options['width']; add_image_size( $size, $options['width'], $options['height'], $options['resize'] ); $file = wp_get_attachment_url($id); $file = str_replace(get_option('siteurl'), ABSPATH, $file); $a = image_make_intermediate_size( $file, $options['width'], $options['height'], $options['crop']); $as = explode('/', $file); $original_file = $as[count($as) - 1]; // $b = image_get_intermediate_size($id, $size); //{ $new_file = $a['file']; } // Churn out some HTML $attr = array('class' => 'mf_image attachment-' . $id, 'id' => 'attachment-' . $id); $b = wp_get_attachment_image($id, $size, false, $attr); if ($new_file) $b = str_replace($original_file, $new_file, $b); echo $before. $b . $after; return true; } /* ** more_fields_template_action () ** ** Remplate action to get content of a box. */ function more_fields_template_action ($title, $options = array()) { get_box($title, $options); } add_action('more_fields', 'more_fields_template_action', 10, 2); /* // I'm duplicating this function here - it's in the admin object too. function mf_get_boxes() { global $more_fields_boxes, $more_fields; $more_fields = $more_fields->get_data() ; //get_option('more_fields_boxes'); if (!is_array($more_fields)) $more_fields = array(); if (!is_array($more_fields_boxes)) $more_fields_boxes = array(); foreach (array_keys($more_fields_boxes) as $key) $more_fields[$key] = $more_fields_boxes[$key]; return $more_fields; } */ ?> Thanks again
  2. I have a drop down field from a wordpress plugin (morefields) and can select 1 of 4 colours. Red, Blue, Green, Red. The code in the 2nd line shows the selected value as above (1 of the 4 colours) This is part of a wordpress loop if that helps.. Shown below.. <?php if ( is_user_logged_in() ) { $user_id = get_current_user_id(); query_posts( "author=$user_id&posts_per_page=10" );?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <ul> <li> <strong>Status: </strong><?php more_fields('status') ?> <?php if (more_fields('status')=="Red") echo "Your account is currently undergoing judgement"; elseif (more_fields('status')=="Green") echo "Your account is currently Live"; elseif (more_fields('status')=="Yellow") echo "Your account is currently undergoing site visits"; elseif (more_fields('status')=="Blue") echo "Your account is currently undergoing insolvency/liquidation";?> </li> </ul> </ul> <?php posts_nav_link(); ?> <?php endwhile; else: ?> <p><?php _e('You Currently Have No Debtors'); ?></p> <?php endif; ?> thanks
  3. thanks for the response, the more fields is from a wordpress plugin. All I really know is <?php more_fields('status') ?> shows one of 4 colours selected in wordpress. sorry I can't provide any more information
  4. I am wanting to echo one of these 4 statements depending on the 'status' value. Currently it is showing the status value on the 2nd line but not the statement below.. <li> <strong>Status: </strong><?php more_fields('status') ?> <?php if (more_fields('status')=="Red") echo "Your account is currently undergoing judgement"; elseif (more_fields('status')=="Green") echo "Your account is currently Live"; elseif (more_fields('status')=="Yellow") echo "Your account is currently undergoing site visits"; elseif (more_fields('status')=="Blue") echo "Your account is currently undergoing insolvency/liquidation";?> </li> any help appreciated. Thanks, Jake
  5. I have searched and searched for this. It may be it doesn't exist or I may not be describing/ searching for the right thing! Using wordpress I have a list of current jobs(custom taxonomy). I need to able to assign jobs in this list to my users. For example I enter the details for a new job and can then select a user from a drop down menu. This will then be displayed on the front page depending on what user is logged in. I hope that made sense, any help much appreciated.
  6. That' s brilliant thanks for the help! I have changed it slightly, as below, but it is now working. <div class="grid_12" id="loggedin" style="background-color: <?php global $current_user; get_currentuserinfo(); echo $current_user->status ;?>"> I have also sorted out my css and id's One more question regarding the colors.. So this is now setting BLUE etc as the background colour. Can this be changed to a hex color? so for example if ($current_user->status=="BLUE") i can asign the color #003954 Thanks again
  7. Hi, I have looked everywhere for a way to do this and would be grateful for a pointer in the right direction. I want to change the background color of the div with the id of "loggedin", depending on the status. The status currently echos text depending on the value. <div class="grid_12" id="loggedin"> <div> <ul id="loggedin"> <li><?php global $current_user; get_currentuserinfo(); echo 'Status : ' . $current_user->status . "\n";?></li> <li> <?php if ($current_user->status=="RED") echo "Red info"; ?> <?php if ($current_user->status=="GREEN") echo "Green info"; ?> <?php if ($current_user->status=="BLUE") echo "Blue info"; ?> <?php if ($current_user->status=="YELLOW") echo "Yellow info"; ?> </li> </div> </div> Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.