Support » Plugin: Pods - Custom Content Types and Fields » Pods pods_by_current_user is not working

  • Resolved nilsbangkok

    (@nilsbangkok)


    Hello community,

    maybe you know this very helpful function pods_by_current_user. For another project it was working fine but for my current project its not working.

    Belong to this post I created a pods_by_current_user.php and uploaded to the plugins-folder. I also tried directly in the function.php but this was also not helping.

    I used this code

    function pods_by_current_user($atts, $content = null) {
    if ( ! function_exists( 'wp_get_current_user' ) )
            return 0;
        $user = wp_get_current_user();
    $user_id = ( isset( $user->ID ) ? (int) $user->ID : 0 );
    $atts[ 'where' ] = 'post_author = ' . (int) $user_id;
    return pods_shortcode( $atts, $content );
    }
    function register_shortcodes() {
    add_shortcode('pods_by_current_user', 'pods_by_current_user');
    }
    add_action( 'init', 'register_shortcodes');

    And this is the shortcode I am using:

    [pods name=”Aufgabe” pods_by_current_user where=”bearbeitungsstand.meta_value = ‘offen'” template=”Aufgabenübersicht”]

    Here are two screenshots… I hope its working. The task “Aufgabe Chris” is created by another user and I should not see this.

    Task overview

    Task detailed

    Does anybody see my mistake? I am quite new user and its not easy to understand all. I am very thankful to everyone who help me with this.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    That shortcode doesn’t look correct, are you sure that’s it? Shouldn’t it be: [pods_by_current_user name=”Aufgabe” where=”bearbeitungsstand.meta_value = ‘offen'” template=”Aufgabenübersicht”]

    Also if you plan on passing arguments to the other shortcode function such as ‘where’, you’ll probably want to check if $atts['where'] has a value already and append to it with an AND.

    Plugin Author Jim True

    (@jimtrue)

    We’ve not heard back from you on this one, so we’re going to have to assume you’ve got it working. We’re going to close this ticket, but if you are still having issues, please reply to this issue, open a new one or join us on our Slack Chat at https://support.pods.io/chat/

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pods pods_by_current_user is not working’ is closed to new replies.