Forum Replies Created

Viewing 9 replies - 31 through 39 (of 39 total)
  • Thread Starter steeleweed

    (@steeleweed)

    Code work bur you disable Editors from editing Admin’s posts, which is a problem. Role Manager plugi N/A or not supported by current WP.
    Is there a way to only block Editors if the post has PHP? We don’t put PHP in posts (altho we could, so I understand your logic), but I would like to use it ina Page (which editors never touch).

    Thread Starter steeleweed

    (@steeleweed)

    Working code in case someone else wants a Page:

    <?php
    /*
    Search for posts by author.
    Returns list of links to posts.
    Requires:
    exec_php plugin
    latestbyauthor plugin
    */
    if (!isset($_POST[‘submit’]))
    {
    echo ‘<form action=”” method=”post”>’;
    echo ‘Author: <input type=”text” name=”who”>
    ‘;
    echo ‘Number:<input type=”text” name=”many” value=”10″>
    ‘;
    echo ‘<input type=”submit” name=”submit” value=”Search”>’;
    echo “</form>”;
    }
    else
    {
    $v = ‘”‘;
    $q = “]”;
    $x = “[latestbyauthor author=”.”$v”;
    $w = $_POST[‘who’];
    $y = “$v”.” show=”.$_POST[‘many’];
    $z = “$x”.”$w”.”$y”.”$q”;

    echo “$z”;]
    }
    ?>

    Thread Starter steeleweed

    (@steeleweed)

    BTW: Thanks for the prompt response – and the plugin.

    Thread Starter steeleweed

    (@steeleweed)

    Fixed the problem by tweaking my cod based on your comment that quotes are needed.

    Instead of framing the name with quotes when entering into the form, I inserted quotes before and after the name when constructing the string for the short code.

    Search for John Smith now yields shortcode:
    [latestbyauthor author=”John Smith” show=10]
    It works!

    Search for John yields shortcode:
    [latestbyauthor author=”John” show=10]
    Quotes not needed but cause no problem. ??

    Thread Starter steeleweed

    (@steeleweed)

    The code posted above lacks some ending apostrophes and/or semi-colons which were in the code – sloppy copy/paste ??

    Thread Starter steeleweed

    (@steeleweed)

    Programming various machines and languages for 50 years.
    My first attempt at PHP.

    Code on the page is:

    <?php
    if (!isset($_POST[‘submit’]))
    {
    echo ‘<form action=”” method=”post”>’;
    echo ‘Author: <input type=”text” name=”who”>
    ‘;
    echo ‘Number:<input type=”text” name=”many” value=”10″>
    ‘;
    echo ‘<input type=”submit” name=”submit” value=”Search”>’;
    echo “</form>”;
    }
    else
    {
    $q = “]”;
    $x = “[latestbyauthor author=”;
    $w = $_POST[‘who’];
    $y = ” show=”.$_POST[‘many’];
    $z = “$x”.”$w”.”$y”.”$q”;
    echo “$z”;
    }
    ?>

    Works for users with no space/blank in name.

    Trying to debug the problem, I removed the [ ] from $q and $x so that $z was just a string instead of shortcode.

    Search for John Doe created string:
    latestbyauthor author=John Doe show=10

    Search for “John Doe” created string:
    latestbyauthor author=\”John Doe\” show=10

    Don’t know where the \s came from. My bad PHP?

    Thread Starter steeleweed

    (@steeleweed)

    FYI:

    Removed the brackets { and } from the string to verify output without executing it as shortcode. Result as expected was:

    latestbyauthor author=John Smith show=10

    Shortcode of [latestbyauthor author=John Smith show=10] fails to display John Smith’s posts. If I searched “John Smith”, PHP passes a string with backslash inserted front & back – and I get my own posts.

    Anything between ‘author=’ and ‘show=’ should be considered username.

    Thread Starter steeleweed

    (@steeleweed)

    Issue 2 resolved via Author Category Plugin. . Issue 3 is on the back burner for now.

    Thread Starter steeleweed

    (@steeleweed)

    Issue 1 resolved – plugin Ultimate Category Excluder was used to prevent Newswire category from showing on Front Page.

    Issues 2 & 3 still unresolved

Viewing 9 replies - 31 through 39 (of 39 total)