You can use boost::bind (or std::bind if your compiler supports that part of C++11 yet):
void foo(const std_msgs::StringConstPtr& msg, uint32_t custom_value)
{
}
ros::Subscriber sub = nh.subscribe<std_msgs::String>("my_topic", 1, boost::bind(foo, _1, 5));
Or if it were a class method:
MyClass c;
ros::Subscriber sub = nh.subscribe<std_msgs::String>("my_topic", 1, boost::bind(&MyClass::foo, &c, _1, 5));
Note that you need to explicitly specify the template parameter here because it cannot be deduced from the value returned by bind().