Title: integrating the widget within a php function code
Last modified: August 24, 2016

---

# integrating the widget within a php function code

 *  [Omid Reza Rajabi](https://wordpress.org/support/users/orrajabi/)
 * (@orrajabi)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/integrating-the-widget-within-a-php-function-code/)
 * Hi,
    I am using a php function which lets me restrict some parts of my posts 
   to be visible only to the site members. In my post editor I put the restricted
   content between [member] and [/member] short codes and when a non-member visits
   the page, he sees a text instead of the restricted content which says “You need
   to be a member to see this part”. I need to include the social login widget within
   that message which a non-member sees on the page. I don’t know how to do that.
   I need a kind helping hand in this regard. Lots of thanks in advance. The restricting
   php function that I use is as follows (I have included it in my theme’s function.
   php file):
 *     ```
       add_shortcode( 'member', 'member_check_shortcode' );
   
       function member_check_shortcode( $atts, $content = null ) {
       	 if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
       		return do_shortcode($content);
       	return '<div style="background-color: #DDEEFF; padding: 10px; border: 2px dotted navy"><h4 style="background-color: navy;padding: 0px;text-align: center"><b><font color="white">You need to be a member to see this part</font></b></h4></div>';
       }
       ```
   
 * I need to show the social login widget in that message box which replaces restricted
   content. Thanks for your kind help in advance.
    Best, Omid
 * [https://wordpress.org/plugins/wordpress-social-login/](https://wordpress.org/plugins/wordpress-social-login/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [headonfire](https://wordpress.org/support/users/headonfire/)
 * (@headonfire)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/integrating-the-widget-within-a-php-function-code/#post-6134639)
 * You can try outputting the login form with `wp_login_form();` function right 
   where you need it. The WSL social block should be there.
 *  Thread Starter [Omid Reza Rajabi](https://wordpress.org/support/users/orrajabi/)
 * (@orrajabi)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/integrating-the-widget-within-a-php-function-code/#post-6134646)
 * Thanks for your reply. Since I am still very novice in coding, could you please
   give me more specific instructions as what to do and where and how to include
   it?
    Thanks a lot
 *  [headonfire](https://wordpress.org/support/users/headonfire/)
 * (@headonfire)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/integrating-the-widget-within-a-php-function-code/#post-6134658)
 * Try this:
 *     ```
       add_shortcode( 'member', 'member_check_shortcode' );
   
       function member_check_shortcode( $atts, $content = null ) {
   
           if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
               return do_shortcode($content);
   
           // prepare arguments for login form
           // see https://codex.wordpress.org/Function_Reference/wp_login_form
           // for all parameters
           $args = array(
               'echo' => false,
           );
   
           // get login form html
           $login_form = wp_login_form( $args );
   
           // prepare all html
           $output = '<div style="background-color: #DDEEFF; padding: 10px; border: 2px dotted navy">';
           $output .= '<h4 style="background-color: navy;padding: 0px;text-align: center; font-weight: bold; color: white;">You need to be a member to see this part</h4>';
           $output .= $login_form;
           $output .= '</div>';
   
           return $output;
   
       }
       ```
   
 * Haven’t tested it but should work. Let me know if anything is broken.
 * And it would be good to move the styles out of the tags (div/h4) and place them
   in your stylesheet.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘integrating the widget within a php function code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wordpress-social-login_a1a2bc.svg)
 * [WordPress Social Login](https://wordpress.org/plugins/wordpress-social-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-social-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-social-login/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-social-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-social-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-social-login/reviews/)

## Tags

 * [integration](https://wordpress.org/support/topic-tag/integration/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 3 replies
 * 2 participants
 * Last reply from: [headonfire](https://wordpress.org/support/users/headonfire/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/integrating-the-widget-within-a-php-function-code/#post-6134658)
 * Status: not resolved