Skip to:
Content
Pages
Categories
Search
Top
Bottom

Favourites in Sidebar

  • @wp_new_user

    Participant

    Hi all,

    I have been trying to add Favourites for the logged in user to the sidebar.
    I have created a simple plugin that adds a widget to the sidebar, the problem is I cannot make the widget show activities or favourites in its content.

    I took the widget code from wordpress codex I guess:
    Here’s the part that should show the content:


    // Creating widget front-end
    // This is where the action happens
    public function widget( $args, $instance ) {
    $title = apply_filters( 'widget_title', $instance['title'] );

    // before and after widget arguments are defined by themes
    echo $args['before_widget'];
    if ( ! empty( $title ) )
    echo $args['before_title'] . $title . $args['after_title'];

    // This is where you run the code and display the output
    echo __( 'my user id is: ', 'wpb_widget_domain' );
    echo bp_loggedin_user_id();
    // the above 2 lines make it show my user id, this is just for testing

    // here I want to add my favourites, I found this to filter the activities
    // if ( bp_has_activities( bp_ajax_querystring( 'activity' ).'&scope=favourites' ) ) :
    // but I don't know how to place it here, whatever way I try it either returns an error or nothing

    if ( bp_has_activities( bp_ajax_querystring( 'activity' ).'&scope=favourites' ) ) :

    echo $args['after_widget'];
    }

    Can you please tell me how to make it.

    Thank you!
    Leo

Viewing 6 replies - 1 through 6 (of 6 total)
  • @shanebp

    Moderator

    returns an error

    And the error is ?

    @shanebp

    Moderator

    @wp_new_user

    Participant

    Hi @shanebp,
    here are the errors:

    1)
    if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ).’&scope=favourites’ ) ) :
    the error is:
    Parse error: syntax error, unexpected ‘}’ in /homepages/38/d602737955/htdocs/web/wp-content/plugins/asplugin/asplugin.php on line 42

    2)
    echo if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ).’&scope=favourites’ ) ) :;
    the error is:
    Parse error: syntax error, unexpected ‘if’ (T_IF) in /homepages/38/d602737955/htdocs/web/wp-content/plugins/asplugin/asplugin.php on line 38

    3)
    echo bp_ajax_querystring( ‘activity’ ).’&scope=favourites’;
    it prints on screen only: &scope=favourites

    Thank you!

    @shanebp

    Moderator

    Re #1 – Make sure all quotes are this ' and not this `. Iow. not slanted

    @wp_new_user

    Participant

    It is '. anything else that looks erroneous?

    @shanebp

    Moderator

    You aren’t providing enough info.
    You might get feedback on your code if you create a gist and post the link here.
    Please do not copy & paste your plugin code on this site.

    You could also learn by studying the code in the plugin linked above.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Favourites in Sidebar’ is closed to new replies.
Skip to toolbar