• windyjon2

    (@windyjon2)


    Hi,

    I’ve added a custom field, which I’m using as a flag. If the field exists, then ‘highlight’ the post.

    Is it possible for a site user (not an admin or a registered user) to set this custom field from the front-end, rather than the back-end?

    i.e. text or button – ‘Would you like to highlight this post?’
    Clicking on this would set the custom field/flag to ‘highlighted’.

    Any advice would be greatly appreciated. I’ve been looking around for hours and haven’t found anything at all. Quite lost really.

    As ever, many thanks in advance:

    Windyjon

Viewing 5 replies - 1 through 5 (of 5 total)
  • Dgold

    (@dgold)

    I have not heard of a plugin for doing that. ??

    The nearest thing I could think of is the plugin, Vote It Up. This is like a “Digg” for your own blog, that lets your users vote a post until it rises to the homepage.
    https://www.ads-software.com/extend/plugins/vote-it-up/

    Good luck with your idea!

    churchthemer

    (@churchthemer)

    Do you want the post to be highlighted for all visitors or just the visitor that clicked the front end highlight button?

    Thread Starter windyjon2

    (@windyjon2)

    Hiya, Thanks for the ideas.

    @churchthemer – The post would be highlighted for ALL visitors.

    @dgold – Your suggestion for vote-it-up is helpful. That plugin does all sorts of complicated things, but deep down its taking interaction from the visitor and using it to amend an entry in a table. Which is exactly what I’m looking to do. I’ll have a go at dissecting it later today.

    churchthemer

    (@churchthemer)

    You can add a link or form button that contains the current posts id as the value.

    When the button is submitted or linked clicked you can write a little function in the functions.php file of your theme folder to check for it via GET or POST. You can then grab the id of the post and update the wp_postmeta table of your wordpress db.

    For example.

    A link might look like this:

    <?php bloginfo(‘template_url’); ?>?action=highlite&id=<?php the_ID(); ?>

    Then your function would look like:
    (note: the below function is just an example to get you started. It has not been tested for functionality or security)

    function highlite_post(){
      global $wpdb;
      if($GET['action'] == "highlite" && is_int($GET['id']){
      $id = $wpdb->escape($GET['id']);
      $update = "UPDATE wp_postmeta SET meta_value = 1 WHERE meta_key = 'highlite' AND post_id = $id";
      $results = $wpdb->query($update);
     }

    then you just need to call the function below your new function

    highlite_post();

    Hope that helps.

    Thread Starter windyjon2

    (@windyjon2)

    That’s very helpful. I couldn’t have worked that out on my own. I’ll build something based on your code snippet this weekend. Its kind of pushing the limits of my wordpress knowledge, but fingers crossed.

    Many thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Changing custom fields from the front end?’ is closed to new replies.