• Resolved carolinagregorio

    (@carolinagregorio)


    Hi, I’m a web developer and I’m using this plugin for one of my projects. Is it possible to duplicate the Follow Bar so that it directs a different user depending on the page? Is this option contemplated somewhere?Regards!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author vaakash

    (@vaakash)

    Hi @carolinagregorio,

    It is doable. I’ll get back to you on this..

    Thanks,
    Aakash

    Thread Starter carolinagregorio

    (@carolinagregorio)

    Thanks for answering Aakash. What good news! I hope your answer soon, since I must deliver this project in a short time.
    Regards! (:

    Plugin Author vaakash

    (@vaakash)

    Looking at your requirement where you need to have different URL based on post/page you have to make a minor change to the plugin code and add a function outside the plugin.

    Add below line to WP Socializer -> core -> templates.php after line 329 after the for loop.

    $btn_obj = apply_filters( 'wpsr_mod_followbar_button', $btn_obj );

    Add the below function anywhere in your theme. You have to expand this function based on what URL to you have to set based on the page being viewed.

    Below function has an example of facebook button URL being changed in contact page.

    function change_follow_bar_url( $btn ){
       
       $id = key( (array) $btn );
       
       if( is_page( 'contact' ) ){
           if( $id == 'facebook' ){
               $btn->$id->url = 'https://my facebook URL for contact page';
           }
       }
       
       return $btn;
       
    }
    add_filter( 'wpsr_mod_followbar_button', 'change_follow_bar_url', 1 );

    Thanks,
    Aakash

    Thread Starter carolinagregorio

    (@carolinagregorio)

    Hello again! I followed the instructions to the letter and I can’t get the url to change. I show you how the code is now, let me know if you see that it is doing something wrong.

    templates.php:

     foreach( $btns as $btn_obj ){
                ...
            }
            
      $btn_obj = apply_filters( 'wpsr_mod_followbar_button', $btn_obj );

    functions.php:

    function change_follow_bar_url( $btn ){
       $id = key( (array) $btn );
       if( is_page( 'ministry-a' ) ){
           if( $id == 'facebook' ){
               $btn->$id->url = 'https://www.facebook.com/';
           }
       }
       return $btn;
    }
    add_filter( 'wpsr_mod_followbar_button', 'change_follow_bar_url', 1 );

    The changes should be reflected in: https://floridaconference2.ethecenter.com/ministry-a

    Regards!

    Plugin Author vaakash

    (@vaakash)

    Hi @carolinagregorio,

    It works for me. I guess it has to do with the is_page() being false always.

    Can you please try the page id instead of name like is_page( 37563 ) ?

    If incase to further debug, please print the below line and see what is the context of the page. Sometimes theme can manipulate the context of the post.

    global $post;
    print_r( $post );

    If the results are of different page than ministry-a then theme is manipulating the context.

    Please do try both and let me know.

    Thanks,
    Aakash

    Thread Starter carolinagregorio

    (@carolinagregorio)

    Nothing worked for me. I confirmed that the page name and id were well written. I even did the test of removing the page filter so that it applies to all in general and the link didn’t change either. Does that make me wonder if there will be a problem with the rest of the code?
    Thanks for the patience.

    Plugin Author vaakash

    (@vaakash)

    I just noticed that you have added the apply_filters after closing the for loop. Actually I meant after the for loop line.

    Can you please add the filter like this in the screenshot ?
    The apply_filers line should come inside the for loop, first line.

    https://i.snipboard.io/C26KOL.jpg

    
            foreach( $btns as $btn_obj ){
    
                $btn_obj = apply_filters( 'wpsr_mod_followbar_button', $btn_obj );
    .
    .
    

    Thanks,
    Aakash

    Thread Starter carolinagregorio

    (@carolinagregorio)

    clearly that was it! Hahaha
    problem solved, thank you very much for your time!

    Plugin Author vaakash

    (@vaakash)

    Cool !
    Please do rate and review the plugin !

    Thanks,
    Aakash

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘duplicate the Follow Bar’ is closed to new replies.