Specific Part of Post for Specific User in Wordpress


I am developing a membership based website in wordpress where I installed S2Member plugin and I show a user a welcome page with some quick links. I am now stuck at the point where I want to show specific links for specific usernames. I installed a plugin named peter's login redirect that shows a specific login page to the user but it didn;t work for me as I am already using a S2 Member plugin.

Is there any other way to show a specific link/button/post-part for the specific user?


I think the easiest way is using a <a href="http://codex.wordpress.org/Shortcode_API" rel="nofollow">Shortcode</a>, you can detect the user name, user role or something else contained in the WP_User object:

<?php /** * Plugin Name: (SO) Welcome Shortcode */ add_shortcode( 'welcome', 'welcome_so_23702194' ); function welcome_so_23702194( $atts, $content = null ) { $user = get_userdata( get_current_user_id() ); if( !$user ) // Normal visitor, nor logged in return ''; # Use the following to inspect the object, and do at the end --> return $debug; // $debug = '<pre>' . print_r( $user, true ) . '</pre>'; if( 'brasofilo' == $user->data->user_login ) $output = "Hello, brasofilo!"; elseif( in_array( 'administrator', $user->roles ) ) $output = "Hello, admininstrator user"; else $output = ''; return $output; }

Then, in your Welcome page add the shortcode in the middle of the content [welcome].


  • Updating MS Access Database from Datagridview
  • vertically output the two dimensional array
  • counting islands in R csv
  • MySQl, join/merge 2 tables without shared column and ordering by a common column
  • D: how to extract data from archive?
  • Matlab FFT and FFTW
  • Login to a website using python
  • About multiple inheritance and ambiguity
  • Facebook Messenger Platform - Detect user typing
  • Ionic storage “get” returns null only on the second call within method
  • Using MouseListener to select a range of cells in a grid
  • What does “t” refer to in this SQL?
  • pip in virtualenv gets ConnectTimeoutError
  • CERN ROOT exporting data to plain text
  • SetWindowsHookEx does not react on media keys
  • Jquery popup on mouse over of calendar control
  • Element.tagName for python not working
  • Django simple Captcha “No module named fields” error
  • Webgrid not refreshing after delete MVC
  • Jquery UI tool tip close icon
  • Why does access(2) check for real and not effective UID?
  • Django rest serializer Breaks when data exists
  • Recording logins for password protected directories
  • Is there any way to access browser form field suggestions from JavaScript?
  • Controls, properties, events and timers running in design time
  • output of program is not same as passed argument
  • Can I make an Android app that runs a web view in Chrome 39?
  • Updated Ionic CLI but shows previous version (Windows)
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Traverse Array and Display in markup
  • Comma separated Values
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Getting error when using KSoap library to consume .NET web services
  • Trying to get generic when generic is not available
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • need help with bizarre java.net.HttpURLConnection behavior
  • Qt: Run a script BEFORE make
  • How to load view controller without button in storyboard?